ez-common-ts/lib/commons/record-util.d.ts
2024-01-30 11:09:07 +08:00

34 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { UnwrapNestedRefs } from "vue";
export declare enum RecordClearMode {
delete = 2,
reset = 1
}
export declare const withRecord: (obj: UnwrapNestedRefs<Record<string, any>>) => {
clear: (mode?: RecordClearMode) => void;
replace: (newVal: UnwrapNestedRefs<Record<string, any>>) => void;
};
/**
* 这是一个泛型函数,接受任意个数的数组作为参数,并返回一个对象。
* 该对象包含两个方法test 和 path。
* test 方法用于测试所有数组的元素是否相等,
* path 方法用于测试所有数组的指定路径的值是否相等。
* @param arrays
* @returns
*/
export declare function assignRecords<T extends Record<string, any>>(...arrays: T[][]): {
test: (equal?: ((l: T, r: T) => boolean) | undefined) => T[];
path: (...paths: string[]) => T[];
};
/**
*
* 接受一个目标对象和多个源对象作为参数,并返回合并后的对象。
* 它会将源对象的属性复制到目标对象中,
* 如果多个源对象有同名属性,
* 则最后的属性值将覆盖前面的属性值。
* @param target 目标对象
* @param sources 来源对象参数
* @returns 目标对象
*/
export declare const extendRecord: <T extends Record<string, any>>(target: T, ...sources: (T | undefined)[]) => T;