typescript-immutable-utils
Version:
Type-safe immutability helpers for simple objects and arrays
12 lines (11 loc) • 660 B
TypeScript
export declare type Dict<V> = {
[key: string]: V;
};
export declare function createDict<V>(): Dict<V>;
export declare function copyDict<V>(dict: Dict<V>): Dict<V>;
export declare function hasKey(dict: Dict<any>, key: any): boolean;
export declare function mapValues<T, R>(dict: Dict<T>, map: (value: T, key: string) => R): Dict<R>;
export declare function union<V>(target: Dict<V>, source: Dict<V>): Dict<V>;
export declare function setKey<V>(dict: Dict<V>, key: any, value: V): Dict<V>;
export declare function removeKey<V>(dict: Dict<V>, ...keys: any[]): Dict<V>;
export declare function fromKeys<V>(keys: any[], values: V | ((key: any) => V)): Dict<V>;