@solid-primitives/utils 7.0.0-next.4 → 7.0.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,117 +1,116 @@
1
1
  /* @ts-self-types="./array.d.ts" */
2
2
  import { AnyClass, ItemsOf, Many } from "../types.js";
3
+ import "../index.js";
3
4
  import { FlattenArray, MappingFn, Predicate } from "./types.js";
4
-
5
5
  //#region src/immutable/array.d.ts
6
6
  /**
7
- * non-mutating `Array.prototype.push()`
8
- * @returns changed array copy
9
- */
10
- declare const push: <T>(list: readonly T[], ...items: T[]) => T[];
11
- /**
12
- * non-mutating function that drops n items from the array start.
13
- * @returns changed array copy
14
- *
15
- * @example
16
- * ```ts
17
- * const newList = drop([1,2,3])
18
- * newList // => [2,3]
19
- *
20
- * const newList = drop([1,2,3], 2)
21
- * newList // => [3]
22
- * ```
23
- */
24
- declare const drop: <T>(list: T[], n?: number) => T[];
25
- /**
26
- * non-mutating function that drops n items from the array end.
27
- * @returns changed array copy
28
- *
29
- * @example
30
- * ```ts
31
- * const newList = dropRight([1,2,3])
32
- * newList // => [1,2]
33
- *
34
- * const newList = dropRight([1,2,3], 2)
35
- * newList // => [1]
36
- * ```
37
- */
38
- declare const dropRight: <T>(list: T[], n?: number) => T[];
39
- /**
40
- * standalone `Array.prototype.filter()` that filters out passed item
41
- * @returns changed array copy
42
- */
43
- declare const filterOut: <T>(list: readonly T[], item: T) => T[] & {
7
+ * non-mutating `Array.prototype.push()`
8
+ * @returns changed array copy
9
+ */
10
+ export declare const push: <T>(list: readonly T[], ...items: T[]) => T[];
11
+ /**
12
+ * non-mutating function that drops n items from the array start.
13
+ * @returns changed array copy
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const newList = drop([1,2,3])
18
+ * newList // => [2,3]
19
+ *
20
+ * const newList = drop([1,2,3], 2)
21
+ * newList // => [3]
22
+ * ```
23
+ */
24
+ export declare const drop: <T>(list: T[], n?: number) => T[];
25
+ /**
26
+ * non-mutating function that drops n items from the array end.
27
+ * @returns changed array copy
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const newList = dropRight([1,2,3])
32
+ * newList // => [1,2]
33
+ *
34
+ * const newList = dropRight([1,2,3], 2)
35
+ * newList // => [1]
36
+ * ```
37
+ */
38
+ export declare const dropRight: <T>(list: T[], n?: number) => T[];
39
+ /**
40
+ * standalone `Array.prototype.filter()` that filters out passed item
41
+ * @returns changed array copy
42
+ */
43
+ export declare const filterOut: <T>(list: readonly T[], item: T) => T[] & {
44
44
  removed: number;
45
45
  };
46
46
  /**
47
- * standalone `Array.prototype.filter()`
48
- * @returns changed array copy
49
- */
50
- declare function filter<T>(list: readonly T[], predicate: Predicate<T>): T[] & {
47
+ * standalone `Array.prototype.filter()`
48
+ * @returns changed array copy
49
+ */
50
+ export declare function filter<T>(list: readonly T[], predicate: Predicate<T>): T[] & {
51
51
  removed: number;
52
52
  };
53
53
  /**
54
- * non-mutating `Array.prototype.sort()` as a standalone function
55
- * @returns changed array copy
56
- */
57
- declare const sort: <T>(list: T[], compareFn?: (a: T, b: T) => number) => T[];
58
- /**
59
- * standalone `Array.prototype.map()` function
60
- */
61
- declare const map: <T, V>(list: readonly T[], mapFn: MappingFn<T, V>) => V[];
62
- /**
63
- * standalone `Array.prototype.slice()` function
64
- */
65
- declare const slice: <T>(list: readonly T[], start?: number, end?: number) => T[];
66
- /**
67
- * non-mutating `Array.prototype.splice()` as a standalone function
68
- * @returns changed array copy
69
- */
70
- declare const splice: <T>(list: readonly T[], start: number, deleteCount?: number, ...items: T[]) => T[];
71
- /**
72
- * non-mutating `Array.prototype.fill()` as a standalone function
73
- * @returns changed array copy
74
- */
75
- declare const fill: <T>(list: readonly T[], value: T, start?: number, end?: number) => T[];
76
- /**
77
- * Creates a new array concatenating array with any additional arrays and/or values.
78
- * @param ...a values or arrays
79
- * @returns new concatenated array
80
- */
81
- declare function concat<A extends any[], V extends ItemsOf<A>>(...a: A): Array<V extends any[] ? ItemsOf<V> : V>;
82
- /**
83
- * Remove item from array
84
- * @returns changed array copy
85
- */
86
- declare const remove: <T>(list: readonly T[], item: T, ...insertItems: T[]) => T[];
87
- /**
88
- * Remove multiple items from an array
89
- * @returns changed array copy
90
- */
91
- declare const removeItems: <T>(list: readonly T[], ...items: T[]) => T[];
92
- /**
93
- * Flattens a nested array into a one-level array
94
- * @returns changed array copy
95
- */
96
- declare const flatten: <T extends any[]>(arr: T) => FlattenArray<T>[];
97
- /**
98
- * Sort an array by object key, or multiple keys
99
- * @returns changed array copy
100
- */
101
- declare const sortBy: <T>(arr: T[], ...paths: T extends object ? (Many<keyof T> | Many<(item: T) => any>)[] : Many<(item: T) => any>[]) => T[];
102
- /**
103
- * Returns a subset of items that are instances of provided Classes
104
- * @param list list of original items
105
- * @param ...classes list or classes
106
- * @returns changed array copy
107
- */
108
- declare const filterInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Extract<T, InstanceType<ItemsOf<I>>>[];
109
- /**
110
- * Returns a subset of items that aren't instances of provided Classes
111
- * @param list list of original items
112
- * @param ...classes list or classes
113
- * @returns changed array copy
114
- */
115
- declare const filterOutInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Exclude<T, InstanceType<ItemsOf<I>>>[];
116
- //#endregion
117
- export { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice };
54
+ * non-mutating `Array.prototype.sort()` as a standalone function
55
+ * @returns changed array copy
56
+ */
57
+ export declare const sort: <T>(list: T[], compareFn?: (a: T, b: T) => number) => T[];
58
+ /**
59
+ * standalone `Array.prototype.map()` function
60
+ */
61
+ export declare const map: <T, V>(list: readonly T[], mapFn: MappingFn<T, V>) => V[];
62
+ /**
63
+ * standalone `Array.prototype.slice()` function
64
+ */
65
+ export declare const slice: <T>(list: readonly T[], start?: number, end?: number) => T[];
66
+ /**
67
+ * non-mutating `Array.prototype.splice()` as a standalone function
68
+ * @returns changed array copy
69
+ */
70
+ export declare const splice: <T>(list: readonly T[], start: number, deleteCount?: number, ...items: T[]) => T[];
71
+ /**
72
+ * non-mutating `Array.prototype.fill()` as a standalone function
73
+ * @returns changed array copy
74
+ */
75
+ export declare const fill: <T>(list: readonly T[], value: T, start?: number, end?: number) => T[];
76
+ /**
77
+ * Creates a new array concatenating array with any additional arrays and/or values.
78
+ * @param ...a values or arrays
79
+ * @returns new concatenated array
80
+ */
81
+ export declare function concat<A extends any[], V extends ItemsOf<A>>(...a: A): Array<V extends any[] ? ItemsOf<V> : V>;
82
+ /**
83
+ * Remove item from array
84
+ * @returns changed array copy
85
+ */
86
+ export declare const remove: <T>(list: readonly T[], item: T, ...insertItems: T[]) => T[];
87
+ /**
88
+ * Remove multiple items from an array
89
+ * @returns changed array copy
90
+ */
91
+ export declare const removeItems: <T>(list: readonly T[], ...items: T[]) => T[];
92
+ /**
93
+ * Flattens a nested array into a one-level array
94
+ * @returns changed array copy
95
+ */
96
+ export declare const flatten: <T extends any[]>(arr: T) => FlattenArray<T>[];
97
+ /**
98
+ * Sort an array by object key, or multiple keys
99
+ * @returns changed array copy
100
+ */
101
+ export declare const sortBy: <T>(arr: T[], ...paths: T extends object ? (Many<keyof T> | Many<(item: T) => any>)[] : Many<(item: T) => any>[]) => T[];
102
+ /**
103
+ * Returns a subset of items that are instances of provided Classes
104
+ * @param list list of original items
105
+ * @param ...classes list or classes
106
+ * @returns changed array copy
107
+ */
108
+ export declare const filterInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Extract<T, InstanceType<ItemsOf<I>>>[];
109
+ /**
110
+ * Returns a subset of items that aren't instances of provided Classes
111
+ * @param list list of original items
112
+ * @param ...classes list or classes
113
+ * @returns changed array copy
114
+ */
115
+ export declare const filterOutInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Exclude<T, InstanceType<ItemsOf<I>>>[];
116
+ //#endregion
@@ -1,31 +1,30 @@
1
1
  /* @ts-self-types="./copy.d.ts" */
2
2
  //#region src/immutable/copy.d.ts
3
3
  /** make shallow copy of an array */
4
- declare const shallowArrayCopy: <T>(array: readonly T[]) => T[];
4
+ export declare const shallowArrayCopy: <T>(array: readonly T[]) => T[];
5
5
  /** make shallow copy of an object */
6
- declare const shallowObjectCopy: <T extends object>(object: T) => T;
6
+ export declare const shallowObjectCopy: <T extends object>(object: T) => T;
7
7
  /** make shallow copy of an array/object */
8
- declare const shallowCopy: <T extends object>(source: T) => T;
8
+ export declare const shallowCopy: <T extends object>(source: T) => T;
9
9
  /**
10
- * apply mutations to the an array without changing the original
11
- * @param array original array
12
- * @param mutator function applying mutations to the copy of source
13
- * @returns changed array copy
14
- */
15
- declare const withArrayCopy: <T>(array: readonly T[], mutator: (copy: T[]) => void) => T[];
10
+ * apply mutations to the an array without changing the original
11
+ * @param array original array
12
+ * @param mutator function applying mutations to the copy of source
13
+ * @returns changed array copy
14
+ */
15
+ export declare const withArrayCopy: <T>(array: readonly T[], mutator: (copy: T[]) => void) => T[];
16
16
  /**
17
- * apply mutations to the an object without changing the original
18
- * @param object original object
19
- * @param mutator function applying mutations to the copy of source
20
- * @returns changed object copy
21
- */
22
- declare const withObjectCopy: <T extends object>(object: T, mutator: (copy: T) => void) => T;
17
+ * apply mutations to the an object without changing the original
18
+ * @param object original object
19
+ * @param mutator function applying mutations to the copy of source
20
+ * @returns changed object copy
21
+ */
22
+ export declare const withObjectCopy: <T extends object>(object: T, mutator: (copy: T) => void) => T;
23
23
  /**
24
- * apply mutations to the an object/array without changing the original
25
- * @param source original object
26
- * @param mutator function applying mutations to the copy of source
27
- * @returns changed object copy
28
- */
29
- declare const withCopy: <T extends object>(source: T, mutator: (copy: T) => void) => T;
30
- //#endregion
31
- export { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy };
24
+ * apply mutations to the an object/array without changing the original
25
+ * @param source original object
26
+ * @param mutator function applying mutations to the copy of source
27
+ * @returns changed object copy
28
+ */
29
+ export declare const withCopy: <T extends object>(source: T, mutator: (copy: T) => void) => T;
30
+ //#endregion
@@ -1,17 +1,16 @@
1
1
  /* @ts-self-types="./number.d.ts" */
2
2
  //#region src/immutable/number.d.ts
3
3
  /** `a + b + c + ...` */
4
- declare function add(...a: number[]): number;
5
- declare function add(...a: string[]): string;
4
+ export declare function add(...a: number[]): number;
5
+ export declare function add(...a: string[]): string;
6
6
  /** `a - b - c - ...` */
7
- declare const substract: (a: number, ...b: number[]) => number;
7
+ export declare const substract: (a: number, ...b: number[]) => number;
8
8
  /** `a * b * c * ...` */
9
- declare const multiply: (a: number, ...b: number[]) => number;
9
+ export declare const multiply: (a: number, ...b: number[]) => number;
10
10
  /** `a / b / c / ...` */
11
- declare const divide: (a: number, ...b: number[]) => number;
11
+ export declare const divide: (a: number, ...b: number[]) => number;
12
12
  /** `a ** b ** c ** ...` */
13
- declare const power: (a: number, ...b: number[]) => number;
13
+ export declare const power: (a: number, ...b: number[]) => number;
14
14
  /** clamp a number value between two other values */
15
- declare const clamp: (n: number, min: number, max: number) => number;
16
- //#endregion
17
- export { add, clamp, divide, multiply, power, substract };
15
+ export declare const clamp: (n: number, min: number, max: number) => number;
16
+ //#endregion
@@ -1,60 +1,60 @@
1
1
  /* @ts-self-types="./object.d.ts" */
2
2
  import { Modify } from "../types.js";
3
+ import "../index.js";
3
4
  //#region src/immutable/object.d.ts
4
5
  /**
5
- * Create a new subset object without the provided keys
6
- *
7
- * @example
8
- * ```ts
9
- * const newObject = omit({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
10
- * newObject // => { c: "baz" }
11
- * ```
12
- */
13
- declare const omit: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Omit<O, K>;
6
+ * Create a new subset object without the provided keys
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const newObject = omit({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
11
+ * newObject // => { c: "baz" }
12
+ * ```
13
+ */
14
+ export declare const omit: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Omit<O, K>;
14
15
  /**
15
- * Create a new subset object with only the provided keys
16
- *
17
- * @example
18
- * ```ts
19
- * const newObject = pick({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
20
- * newObject // => { a:"foo", b:"bar" }
21
- * ```
22
- */
23
- declare const pick: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Pick<O, K>;
16
+ * Create a new subset object with only the provided keys
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const newObject = pick({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
21
+ * newObject // => { a:"foo", b:"bar" }
22
+ * ```
23
+ */
24
+ export declare const pick: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Pick<O, K>;
24
25
  /**
25
- * Get a single property value of an object by specifying a path to it.
26
- */
27
- declare function get<O extends object, K extends keyof O>(obj: O, key: K): O[K];
28
- declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1]>(obj: O, k1: K1, k2: K2): O[K1][K2];
29
- declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2]>(obj: O, k1: K1, k2: K2, k3: K3): O[K1][K2][K3];
30
- declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4): O[K1][K2][K3][K4];
31
- declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3], K5 extends keyof O[K1][K2][K3][K4]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): O[K1][K2][K3][K4][K5];
32
- declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3], K5 extends keyof O[K1][K2][K3][K4], K6 extends keyof O[K1][K2][K3][K4][K5]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): O[K1][K2][K3][K4][K5][K6];
26
+ * Get a single property value of an object by specifying a path to it.
27
+ */
28
+ export declare function get<O extends object, K extends keyof O>(obj: O, key: K): O[K];
29
+ export declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1]>(obj: O, k1: K1, k2: K2): O[K1][K2];
30
+ export declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2]>(obj: O, k1: K1, k2: K2, k3: K3): O[K1][K2][K3];
31
+ export declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4): O[K1][K2][K3][K4];
32
+ export declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3], K5 extends keyof O[K1][K2][K3][K4]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): O[K1][K2][K3][K4][K5];
33
+ export declare function get<O extends object, K1 extends keyof O, K2 extends keyof O[K1], K3 extends keyof O[K1][K2], K4 extends keyof O[K1][K2][K3], K5 extends keyof O[K1][K2][K3][K4], K6 extends keyof O[K1][K2][K3][K4][K5]>(obj: O, k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): O[K1][K2][K3][K4][K5][K6];
33
34
  /**
34
- * Split object properties by keys into multiple object copies with a subset of selected properties.
35
- *
36
- * @param object original object
37
- * @param ...keys keys to pick from the source, or multiple arrays of keys *(for splitting into more than 2 objects)*
38
- * ```ts
39
- * (keyof object)[][] | (keyof object)[]
40
- * ```
41
- * @returns array of subset objects
42
- */
43
- declare function split<T extends object, K extends keyof T>(object: T, ...keys: K[]): [Pick<T, K>, Omit<T, K>];
44
- declare function split<T extends object, K1 extends keyof T, K2 extends keyof T>(object: T, ...keys: [K1[], K2[]]): [Pick<T, K1>, Pick<T, K2>, Omit<T, K1 | K2>];
45
- declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Omit<T, K1 | K2 | K3>];
46
- declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[], K4[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Omit<T, K1 | K2 | K3 | K4>];
47
- declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T, K5 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[], K4[], K5[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Pick<T, K5>, Omit<T, K1 | K2 | K3 | K4 | K5>];
35
+ * Split object properties by keys into multiple object copies with a subset of selected properties.
36
+ *
37
+ * @param object original object
38
+ * @param ...keys keys to pick from the source, or multiple arrays of keys *(for splitting into more than 2 objects)*
39
+ * ```ts
40
+ * (keyof object)[][] | (keyof object)[]
41
+ * ```
42
+ * @returns array of subset objects
43
+ */
44
+ export declare function split<T extends object, K extends keyof T>(object: T, ...keys: K[]): [Pick<T, K>, Omit<T, K>];
45
+ export declare function split<T extends object, K1 extends keyof T, K2 extends keyof T>(object: T, ...keys: [K1[], K2[]]): [Pick<T, K1>, Pick<T, K2>, Omit<T, K1 | K2>];
46
+ export declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Omit<T, K1 | K2 | K3>];
47
+ export declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[], K4[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Omit<T, K1 | K2 | K3 | K4>];
48
+ export declare function split<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T, K5 extends keyof T>(object: T, ...keys: [K1[], K2[], K3[], K4[], K5[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Pick<T, K5>, Omit<T, K1 | K2 | K3 | K4 | K5>];
48
49
  /**
49
- * Merges multiple objects into a single one. Only the first level of properties is merged. An alternative to `{ ...a, ...b, ...c }`.
50
- * @param ...objects objects to merge
51
- * @example
52
- * const d = merge(a, b, c)
53
- */
54
- declare function merge<A extends object, B extends object>(a: A, b: B): Modify<A, B>;
55
- declare function merge<A extends object, B extends object, C extends object>(a: A, b: B, c: C): Modify<Modify<A, B>, C>;
56
- declare function merge<A extends object, B extends object, C extends object, D extends object>(a: A, b: B, c: C, d: D): Modify<Modify<Modify<A, B>, C>, D>;
57
- declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object>(a: A, b: B, c: C, d: D, e: E): Modify<Modify<Modify<Modify<A, B>, C>, D>, E>;
58
- declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(a: A, b: B, c: C, d: D, e: E, f: F): Modify<Modify<Modify<Modify<Modify<A, B>, C>, D>, E>, F>;
59
- //#endregion
60
- export { get, merge, omit, pick, split };
50
+ * Merges multiple objects into a single one. Only the first level of properties is merged. An alternative to `{ ...a, ...b, ...c }`.
51
+ * @param ...objects objects to merge
52
+ * @example
53
+ * const d = merge(a, b, c)
54
+ */
55
+ export declare function merge<A extends object, B extends object>(a: A, b: B): Modify<A, B>;
56
+ export declare function merge<A extends object, B extends object, C extends object>(a: A, b: B, c: C): Modify<Modify<A, B>, C>;
57
+ export declare function merge<A extends object, B extends object, C extends object, D extends object>(a: A, b: B, c: C, d: D): Modify<Modify<Modify<A, B>, C>, D>;
58
+ export declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object>(a: A, b: B, c: C, d: D, e: E): Modify<Modify<Modify<Modify<A, B>, C>, D>, E>;
59
+ export declare function merge<A extends object, B extends object, C extends object, D extends object, E extends object, F extends object>(a: A, b: B, c: C, d: D, e: E, f: F): Modify<Modify<Modify<Modify<Modify<A, B>, C>, D>, E>, F>;
60
+ //#endregion
@@ -1,9 +1,9 @@
1
1
  /* @ts-self-types="./types.d.ts" */
2
2
  import { ItemsOf } from "../types.js";
3
+ import "../index.js";
3
4
  //#region src/immutable/types.d.ts
4
- type Predicate<T> = (item: T, index: number, array: readonly T[]) => boolean;
5
- type MappingFn<T, V> = (item: T, index: number, array: readonly T[]) => V;
6
- type FlattenArray<T> = T extends any[] ? FlattenArray<ItemsOf<T>> : T;
7
- type ModifyValue<O, K extends keyof O, V> = Omit<O, K> & { [key in K]: V };
8
- //#endregion
9
- export { FlattenArray, MappingFn, ModifyValue, Predicate };
5
+ export type Predicate<T> = (item: T, index: number, array: readonly T[]) => boolean;
6
+ export type MappingFn<T, V> = (item: T, index: number, array: readonly T[]) => V;
7
+ export type FlattenArray<T> = T extends any[] ? FlattenArray<ItemsOf<T>> : T;
8
+ export type ModifyValue<O, K extends keyof O, V> = Omit<O, K> & { [key in K]: V; };
9
+ //#endregion
@@ -1,9 +1,8 @@
1
1
  /* @ts-self-types="./update.d.ts" */
2
2
  import { ModifyValue } from "./types.js";
3
-
4
3
  //#region src/immutable/update.d.ts
5
- type UpdateSetter<O, K extends keyof O, V> = V | ((prev: O[K]) => V);
6
- type Update = {
4
+ export type UpdateSetter<O, K extends keyof O, V> = V | ((prev: O[K]) => V);
5
+ export type Update = {
7
6
  <O extends object, K0 extends keyof O, K1 extends keyof O[K0], K2 extends keyof O[K0][K1], K3 extends keyof O[K0][K1][K2], K4 extends keyof O[K0][K1][K2][K3], V>(object: O, k0: K0, k1: K1, k2: K2, k3: K3, k4: K4, setter: UpdateSetter<O[K0][K1][K2][K3], K4, V>): ModifyValue<O, K0, ModifyValue<O[K0], K1, ModifyValue<O[K0][K1], K2, ModifyValue<O[K0][K1][K2], K3, ModifyValue<O[K0][K1][K2][K3], K4, V>>>>>;
8
7
  <O extends object, K0 extends keyof O, K1 extends keyof O[K0], K2 extends keyof O[K0][K1], K3 extends keyof O[K0][K1][K2], V>(object: O, k0: K0, k1: K1, k2: K2, k3: K3, setter: UpdateSetter<O[K0][K1][K2], K3, V>): ModifyValue<O, K0, ModifyValue<O[K0], K1, ModifyValue<O[K0][K1], K2, ModifyValue<O[K0][K1][K2], K3, V>>>>;
9
8
  <O extends object, K0 extends keyof O, K1 extends keyof O[K0], K2 extends keyof O[K0][K1], V>(object: O, k0: K0, k1: K1, k2: K2, setter: UpdateSetter<O[K0][K1], K2, V>): ModifyValue<O, K0, ModifyValue<O[K0], K1, ModifyValue<O[K0][K1], K2, V>>>;
@@ -11,25 +10,24 @@ type Update = {
11
10
  <O extends object, K extends keyof O, V>(object: O, key: K, setter: UpdateSetter<O, K, V>): ModifyValue<O, K, V>;
12
11
  };
13
12
  /**
14
- * Change single value in an object by key. Allows accessign nested objects by passing multiple keys.
15
- *
16
- * Performs a shallow copy of each accessed object.
17
- *
18
- * @param object original source
19
- * @param ...keys keys of sequential accessed objects
20
- * @param value a value to set in place of a previous one, or a setter function.
21
- * ```ts
22
- * V | ((prev: O[K]) => V)
23
- * ```
24
- * a new value doesn't have to have the same type as the original
25
- * @returns changed copy of the original object
26
- *
27
- * @example
28
- * const original = { foo: { bar: { baz: 123 }}};
29
- * const newObj = update(original, "foo", "bar", "baz", prev => prev + 1)
30
- * original // { foo: { bar: { baz: 123 }}}
31
- * newObj // { foo: { bar: { baz: 124 }}}
32
- */
33
- declare const update: Update;
34
- //#endregion
35
- export { Update, UpdateSetter, update };
13
+ * Change single value in an object by key. Allows accessign nested objects by passing multiple keys.
14
+ *
15
+ * Performs a shallow copy of each accessed object.
16
+ *
17
+ * @param object original source
18
+ * @param ...keys keys of sequential accessed objects
19
+ * @param value a value to set in place of a previous one, or a setter function.
20
+ * ```ts
21
+ * V | ((prev: O[K]) => V)
22
+ * ```
23
+ * a new value doesn't have to have the same type as the original
24
+ * @returns changed copy of the original object
25
+ *
26
+ * @example
27
+ * const original = { foo: { bar: { baz: 123 }}};
28
+ * const newObj = update(original, "foo", "bar", "baz", prev => prev + 1)
29
+ * original // { foo: { bar: { baz: 123 }}}
30
+ * newObj // { foo: { bar: { baz: 124 }}}
31
+ */
32
+ export declare const update: Update;
33
+ //#endregion