limu
Version:
A fast js lib of immutable data, based on shallow copy on read and mark modified on write mechanism
39 lines (38 loc) • 1.54 kB
TypeScript
import type { DraftMeta } from '../inner-types';
export declare function nodupPush(list: Array<string | number>, toPush: string | number): void;
export declare function ensureStrKey(maySymbolKey: any): any;
export declare function getKeyStrByPath(keyPath: string[], ensureStr?: boolean): string;
/**
* in: ['a', 'b', Symbol]
* out: ['a', 'b', 'SID_1']
*/
export declare function toKeyStrPath(keyPath: string[], traversal?: boolean): string[];
/**
* out: ['a', 'b', 'SID_1']
* in: ['a', 'b', Symbol]
*/
export declare function toKeyPath(keyStrPath: string[]): string[];
export declare function pushKeyPath(meta: DraftMeta, keyPath: string[], inputKeyStrPath?: string[]): void;
/**
* 删一条路径,并将 keyPath, keyStrPath 重新指向一个存在的路径
*/
export declare function delKeyPath(meta: DraftMeta): void;
/**
* string 获取不到,尝试转为 number 获取
*/
export declare function getMapVal(map: Map<any, any>, key: string): any;
export declare function getVal(obj: any, keyPath: string[]): {
val: any;
isGetted: boolean;
};
export declare function getValByKeyPaths(obj: any, keyPaths: string[][]): {
isGetted: boolean;
val: any;
};
export declare function setVal(obj: any, keyPath: string[], val: any): void;
export declare function setValByKeyPaths(obj: any, keyPaths: string[][], val: any): void;
/**
* in: keyPath [a,b,0,d,0] [[a,b,0], [info,0]]
* out: [[a,b,0,d,0], [info,0,d,0]]
*/
export declare function intersectPath(keyPath: string[], commonKeyPaths: string[][]): string[][];