-
Notifications
You must be signed in to change notification settings - Fork 50
/
object-path-immutable.d.ts
executable file
·24 lines (22 loc) · 1.21 KB
/
object-path-immutable.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type Path = string | ReadonlyArray<number | string>;
interface WrappedObject<T> {
set(path?: Path, value?: any): WrappedObject<T>
push(path?: Path, value?: any): WrappedObject<T>
del(path?: Path): WrappedObject<T>
assign(path?: Path, source?: any): WrappedObject<T>
merge(path?: Path, source?: any): WrappedObject<T>
update(path?: Path, updater?: (formerValue: any) => any): WrappedObject<T>
insert(path?: Path, value?: any, index?: number): WrappedObject<T>
value(): T
}
declare module 'object-path-immutable' {
export function wrap<T>(obj: T): WrappedObject<T>
export function get<T = object, S = any>(src: T, path?: Path, defaultValue?: S): S
export function set<T = object>(src: T, path?: Path, value?: any): T
export function push<T = object>(src: T, path?: Path, value?: any): T
export function del<T = object>(src: T, path?: Path): T
export function assign<T = object>(src: T, path?: Path, source?: any): T
export function merge<T = object>(src: T, path?: Path, source?: any): T
export function update<T = object>(src: T, path?: Path, updater?: (formerValue: any) => any): T
export function insert<T = object>(src: T, path?: Path, value?: any, index?: number): T
}