@solid-primitives/utils 7.0.0-next.0 → 7.0.0-next.2

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,139 +1,133 @@
1
+ /* @ts-self-types="./array.d.ts" */
1
2
  import { compare, ofClass } from "../index.js";
2
3
  import { withArrayCopy } from "./copy.js";
3
4
  import { get } from "./object.js";
4
- /**
5
- * non-mutating `Array.prototype.push()`
6
- * @returns changed array copy
7
- */
8
- export const push = (list, ...items) => withArrayCopy(list, list => list.push(...items));
9
- /**
10
- * non-mutating function that drops n items from the array start.
11
- * @returns changed array copy
12
- *
13
- * @example
14
- * ```ts
15
- * const newList = drop([1,2,3])
16
- * newList // => [2,3]
17
- *
18
- * const newList = drop([1,2,3], 2)
19
- * newList // => [3]
20
- * ```
21
- */
22
- export const drop = (list, n = 1) => list.slice(n);
23
- /**
24
- * non-mutating function that drops n items from the array end.
25
- * @returns changed array copy
26
- *
27
- * @example
28
- * ```ts
29
- * const newList = dropRight([1,2,3])
30
- * newList // => [1,2]
31
- *
32
- * const newList = dropRight([1,2,3], 2)
33
- * newList // => [1]
34
- * ```
35
- */
36
- export const dropRight = (list, n = 1) => list.slice(0, list.length - n);
37
- /**
38
- * standalone `Array.prototype.filter()` that filters out passed item
39
- * @returns changed array copy
40
- */
41
- export const filterOut = (list, item) => filter(list, i => i !== item);
42
- /**
43
- * standalone `Array.prototype.filter()`
44
- * @returns changed array copy
45
- */
46
- export function filter(list, predicate) {
47
- const newList = list.filter(predicate);
48
- newList.removed = list.length - newList.length;
49
- return newList;
5
+ //#region src/immutable/array.ts
6
+ /**
7
+ * non-mutating `Array.prototype.push()`
8
+ * @returns changed array copy
9
+ */
10
+ const push = (list, ...items) => withArrayCopy(list, (list) => list.push(...items));
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
+ const drop = (list, n = 1) => list.slice(n);
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
+ const dropRight = (list, n = 1) => list.slice(0, list.length - n);
39
+ /**
40
+ * standalone `Array.prototype.filter()` that filters out passed item
41
+ * @returns changed array copy
42
+ */
43
+ const filterOut = (list, item) => filter(list, (i) => i !== item);
44
+ /**
45
+ * standalone `Array.prototype.filter()`
46
+ * @returns changed array copy
47
+ */
48
+ function filter(list, predicate) {
49
+ const newList = list.filter(predicate);
50
+ newList.removed = list.length - newList.length;
51
+ return newList;
50
52
  }
51
53
  /**
52
- * non-mutating `Array.prototype.sort()` as a standalone function
53
- * @returns changed array copy
54
- */
55
- export const sort = (list, compareFn) => list.slice().sort(compareFn);
56
- /**
57
- * standalone `Array.prototype.map()` function
58
- */
59
- export const map = (list, mapFn) => list.map(mapFn);
60
- /**
61
- * standalone `Array.prototype.slice()` function
62
- */
63
- export const slice = (list, start, end) => list.slice(start, end);
64
- /**
65
- * non-mutating `Array.prototype.splice()` as a standalone function
66
- * @returns changed array copy
67
- */
68
- export const splice = (list, start, deleteCount = 0, ...items) => withArrayCopy(list, list => list.splice(start, deleteCount, ...items));
69
- /**
70
- * non-mutating `Array.prototype.fill()` as a standalone function
71
- * @returns changed array copy
72
- */
73
- export const fill = (list, value, start, end) => list.slice().fill(value, start, end);
74
- /**
75
- * Creates a new array concatenating array with any additional arrays and/or values.
76
- * @param ...a values or arrays
77
- * @returns new concatenated array
78
- */
79
- export function concat(...a) {
80
- const result = [];
81
- for (const i in a) {
82
- Array.isArray(a[i]) ? result.push(...a[i]) : result.push(a[i]);
83
- }
84
- return result;
54
+ * non-mutating `Array.prototype.sort()` as a standalone function
55
+ * @returns changed array copy
56
+ */
57
+ const sort = (list, compareFn) => list.slice().sort(compareFn);
58
+ /**
59
+ * standalone `Array.prototype.map()` function
60
+ */
61
+ const map = (list, mapFn) => list.map(mapFn);
62
+ /**
63
+ * standalone `Array.prototype.slice()` function
64
+ */
65
+ const slice = (list, start, end) => list.slice(start, end);
66
+ /**
67
+ * non-mutating `Array.prototype.splice()` as a standalone function
68
+ * @returns changed array copy
69
+ */
70
+ const splice = (list, start, deleteCount = 0, ...items) => withArrayCopy(list, (list) => list.splice(start, deleteCount, ...items));
71
+ /**
72
+ * non-mutating `Array.prototype.fill()` as a standalone function
73
+ * @returns changed array copy
74
+ */
75
+ const fill = (list, value, start, end) => list.slice().fill(value, start, end);
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
+ function concat(...a) {
82
+ const result = [];
83
+ for (const i in a) Array.isArray(a[i]) ? result.push(...a[i]) : result.push(a[i]);
84
+ return result;
85
85
  }
86
86
  /**
87
- * Remove item from array
88
- * @returns changed array copy
89
- */
90
- export const remove = (list, item, ...insertItems) => {
91
- const index = list.indexOf(item);
92
- return splice(list, index, 1, ...insertItems);
87
+ * Remove item from array
88
+ * @returns changed array copy
89
+ */
90
+ const remove = (list, item, ...insertItems) => {
91
+ const index = list.indexOf(item);
92
+ return splice(list, index, 1, ...insertItems);
93
93
  };
94
94
  /**
95
- * Remove multiple items from an array
96
- * @returns changed array copy
97
- */
98
- export const removeItems = (list, ...items) => {
99
- const res = [];
100
- for (let i = 0; i < list.length; i++) {
101
- const item = list[i];
102
- const ii = items.indexOf(item);
103
- if (ii !== -1)
104
- items.splice(ii, 1);
105
- else
106
- res.push(item);
107
- }
108
- return res;
95
+ * Remove multiple items from an array
96
+ * @returns changed array copy
97
+ */
98
+ const removeItems = (list, ...items) => {
99
+ const res = [];
100
+ for (let i = 0; i < list.length; i++) {
101
+ const item = list[i];
102
+ const ii = items.indexOf(item);
103
+ if (ii !== -1) items.splice(ii, 1);
104
+ else res.push(item);
105
+ }
106
+ return res;
109
107
  };
110
108
  /**
111
- * Flattens a nested array into a one-level array
112
- * @returns changed array copy
113
- */
114
- export const flatten = (arr) => arr.reduce((flat, next) => flat.concat(Array.isArray(next) ? flatten(next) : next), []);
115
- /**
116
- * Sort an array by object key, or multiple keys
117
- * @returns changed array copy
118
- */
119
- export const sortBy = (arr, ...paths) => flatten(paths).reduce((source, path) => sort(source, (a, b) => typeof path === "function"
120
- ? compare(path(a), path(b))
121
- : compare(get(a, path), get(b, path))), arr);
122
- /**
123
- * Returns a subset of items that are instances of provided Classes
124
- * @param list list of original items
125
- * @param ...classes list or classes
126
- * @returns changed array copy
127
- */
128
- export const filterInstance = (list, ...classes) => (classes.length === 1
129
- ? list.filter(item => ofClass(item, classes[0]))
130
- : list.filter(item => item && classes.some(c => ofClass(item, c))));
131
- /**
132
- * Returns a subset of items that aren't instances of provided Classes
133
- * @param list list of original items
134
- * @param ...classes list or classes
135
- * @returns changed array copy
136
- */
137
- export const filterOutInstance = (list, ...classes) => (classes.length === 1
138
- ? list.filter(item => item && !ofClass(item, classes[0]))
139
- : list.filter(item => item && !classes.some(c => ofClass(item, c))));
109
+ * Flattens a nested array into a one-level array
110
+ * @returns changed array copy
111
+ */
112
+ const flatten = (arr) => arr.reduce((flat, next) => flat.concat(Array.isArray(next) ? flatten(next) : next), []);
113
+ /**
114
+ * Sort an array by object key, or multiple keys
115
+ * @returns changed array copy
116
+ */
117
+ const sortBy = (arr, ...paths) => flatten(paths).reduce((source, path) => sort(source, (a, b) => typeof path === "function" ? compare(path(a), path(b)) : compare(get(a, path), get(b, path))), arr);
118
+ /**
119
+ * Returns a subset of items that are instances of provided Classes
120
+ * @param list list of original items
121
+ * @param ...classes list or classes
122
+ * @returns changed array copy
123
+ */
124
+ const filterInstance = (list, ...classes) => classes.length === 1 ? list.filter((item) => ofClass(item, classes[0])) : list.filter((item) => item && classes.some((c) => ofClass(item, c)));
125
+ /**
126
+ * Returns a subset of items that aren't instances of provided Classes
127
+ * @param list list of original items
128
+ * @param ...classes list or classes
129
+ * @returns changed array copy
130
+ */
131
+ const filterOutInstance = (list, ...classes) => classes.length === 1 ? list.filter((item) => item && !ofClass(item, classes[0])) : list.filter((item) => item && !classes.some((c) => ofClass(item, c)));
132
+ //#endregion
133
+ export { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice };
@@ -1,27 +1,31 @@
1
+ /* @ts-self-types="./copy.d.ts" */
2
+ //#region src/immutable/copy.d.ts
1
3
  /** make shallow copy of an array */
2
- export declare const shallowArrayCopy: <T>(array: readonly T[]) => T[];
4
+ declare const shallowArrayCopy: <T>(array: readonly T[]) => T[];
3
5
  /** make shallow copy of an object */
4
- export declare const shallowObjectCopy: <T extends object>(object: T) => T;
6
+ declare const shallowObjectCopy: <T extends object>(object: T) => T;
5
7
  /** make shallow copy of an array/object */
6
- export declare const shallowCopy: <T extends object>(source: T) => T;
8
+ declare const shallowCopy: <T extends object>(source: T) => T;
7
9
  /**
8
- * apply mutations to the an array without changing the original
9
- * @param array original array
10
- * @param mutator function applying mutations to the copy of source
11
- * @returns changed array copy
12
- */
13
- export 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
+ declare const withArrayCopy: <T>(array: readonly T[], mutator: (copy: T[]) => void) => T[];
14
16
  /**
15
- * apply mutations to the an object without changing the original
16
- * @param object original object
17
- * @param mutator function applying mutations to the copy of source
18
- * @returns changed object copy
19
- */
20
- export 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
+ declare const withObjectCopy: <T extends object>(object: T, mutator: (copy: T) => void) => T;
21
23
  /**
22
- * apply mutations to the an object/array without changing the original
23
- * @param source original object
24
- * @param mutator function applying mutations to the copy of source
25
- * @returns changed object copy
26
- */
27
- export declare const withCopy: <T extends object>(source: T, mutator: (copy: T) => void) => T;
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 };
@@ -1,37 +1,39 @@
1
+ /* @ts-self-types="./copy.d.ts" */
2
+ //#region src/immutable/copy.ts
1
3
  /** make shallow copy of an array */
2
- export const shallowArrayCopy = (array) => array.slice();
4
+ const shallowArrayCopy = (array) => array.slice();
3
5
  /** make shallow copy of an object */
4
- export const shallowObjectCopy = (object) => Object.assign({}, object);
6
+ const shallowObjectCopy = (object) => Object.assign({}, object);
5
7
  /** make shallow copy of an array/object */
6
- export const shallowCopy = (source) => Array.isArray(source) ? shallowArrayCopy(source) : shallowObjectCopy(source);
8
+ const shallowCopy = (source) => Array.isArray(source) ? shallowArrayCopy(source) : shallowObjectCopy(source);
7
9
  /**
8
- * apply mutations to the an array without changing the original
9
- * @param array original array
10
- * @param mutator function applying mutations to the copy of source
11
- * @returns changed array copy
12
- */
13
- export const withArrayCopy = (array, mutator) => {
14
- const copy = shallowArrayCopy(array);
15
- mutator(copy);
16
- return copy;
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
+ const withArrayCopy = (array, mutator) => {
16
+ const copy = shallowArrayCopy(array);
17
+ mutator(copy);
18
+ return copy;
17
19
  };
18
20
  /**
19
- * apply mutations to the an object without changing the original
20
- * @param object original object
21
- * @param mutator function applying mutations to the copy of source
22
- * @returns changed object copy
23
- */
24
- export const withObjectCopy = (object, mutator) => {
25
- const copy = shallowObjectCopy(object);
26
- mutator(copy);
27
- return copy;
21
+ * apply mutations to the an object without changing the original
22
+ * @param object original object
23
+ * @param mutator function applying mutations to the copy of source
24
+ * @returns changed object copy
25
+ */
26
+ const withObjectCopy = (object, mutator) => {
27
+ const copy = shallowObjectCopy(object);
28
+ mutator(copy);
29
+ return copy;
28
30
  };
29
31
  /**
30
- * apply mutations to the an object/array without changing the original
31
- * @param source original object
32
- * @param mutator function applying mutations to the copy of source
33
- * @returns changed object copy
34
- */
35
- export const withCopy = (source, mutator) => Array.isArray(source)
36
- ? withArrayCopy(source, mutator)
37
- : withObjectCopy(source, mutator);
32
+ * apply mutations to the an object/array without changing the original
33
+ * @param source original object
34
+ * @param mutator function applying mutations to the copy of source
35
+ * @returns changed object copy
36
+ */
37
+ const withCopy = (source, mutator) => Array.isArray(source) ? withArrayCopy(source, mutator) : withObjectCopy(source, mutator);
38
+ //#endregion
39
+ export { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy };
@@ -1,6 +1,8 @@
1
- export * from "./copy.js";
2
- export * from "./number.js";
3
- export * from "./update.js";
4
- export * from "./object.js";
5
- export * from "./array.js";
6
- export * from "./types.js";
1
+ /* @ts-self-types="./index.d.ts" */
2
+ import { FlattenArray, MappingFn, ModifyValue, Predicate } from "./types.js";
3
+ import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
4
+ import { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy } from "./copy.js";
5
+ import { add, clamp, divide, multiply, power, substract } from "./number.js";
6
+ import { Update, UpdateSetter, update } from "./update.js";
7
+ import { get, merge, omit, pick, split } from "./object.js";
8
+ export { FlattenArray, MappingFn, ModifyValue, Predicate, Update, UpdateSetter, add, clamp, concat, divide, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, get, map, merge, multiply, omit, pick, power, push, remove, removeItems, shallowArrayCopy, shallowCopy, shallowObjectCopy, slice, sort, sortBy, splice, split, substract, update, withArrayCopy, withCopy, withObjectCopy };
@@ -1,6 +1,7 @@
1
- export * from "./copy.js";
2
- export * from "./number.js";
3
- export * from "./update.js";
4
- export * from "./object.js";
5
- export * from "./array.js";
6
- export * from "./types.js";
1
+ /* @ts-self-types="./index.d.ts" */
2
+ import { shallowArrayCopy, shallowCopy, shallowObjectCopy, withArrayCopy, withCopy, withObjectCopy } from "./copy.js";
3
+ import { get, merge, omit, pick, split } from "./object.js";
4
+ import { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice } from "./array.js";
5
+ import { add, clamp, divide, multiply, power, substract } from "./number.js";
6
+ import { update } from "./update.js";
7
+ export { add, clamp, concat, divide, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, get, map, merge, multiply, omit, pick, power, push, remove, removeItems, shallowArrayCopy, shallowCopy, shallowObjectCopy, slice, sort, sortBy, splice, split, substract, update, withArrayCopy, withCopy, withObjectCopy };
@@ -1,13 +1,17 @@
1
+ /* @ts-self-types="./number.d.ts" */
2
+ //#region src/immutable/number.d.ts
1
3
  /** `a + b + c + ...` */
2
- export declare function add(...a: number[]): number;
3
- export declare function add(...a: string[]): string;
4
+ declare function add(...a: number[]): number;
5
+ declare function add(...a: string[]): string;
4
6
  /** `a - b - c - ...` */
5
- export declare const substract: (a: number, ...b: number[]) => number;
7
+ declare const substract: (a: number, ...b: number[]) => number;
6
8
  /** `a * b * c * ...` */
7
- export declare const multiply: (a: number, ...b: number[]) => number;
9
+ declare const multiply: (a: number, ...b: number[]) => number;
8
10
  /** `a / b / c / ...` */
9
- export declare const divide: (a: number, ...b: number[]) => number;
11
+ declare const divide: (a: number, ...b: number[]) => number;
10
12
  /** `a ** b ** c ** ...` */
11
- export declare const power: (a: number, ...b: number[]) => number;
13
+ declare const power: (a: number, ...b: number[]) => number;
12
14
  /** clamp a number value between two other values */
13
- export declare const clamp: (n: number, min: number, max: number) => number;
15
+ declare const clamp: (n: number, min: number, max: number) => number;
16
+ //#endregion
17
+ export { add, clamp, divide, multiply, power, substract };
@@ -1,37 +1,31 @@
1
- export function add(...a) {
2
- let r = 0;
3
- for (const n of a) {
4
- r += n;
5
- }
6
- return r;
1
+ /* @ts-self-types="./number.d.ts" */
2
+ //#region src/immutable/number.ts
3
+ function add(...a) {
4
+ let r = 0;
5
+ for (const n of a) r += n;
6
+ return r;
7
7
  }
8
8
  /** `a - b - c - ...` */
9
- export const substract = (a, ...b) => {
10
- for (const n of b) {
11
- a -= n;
12
- }
13
- return a;
9
+ const substract = (a, ...b) => {
10
+ for (const n of b) a -= n;
11
+ return a;
14
12
  };
15
13
  /** `a * b * c * ...` */
16
- export const multiply = (a, ...b) => {
17
- for (const n of b) {
18
- a *= n;
19
- }
20
- return a;
14
+ const multiply = (a, ...b) => {
15
+ for (const n of b) a *= n;
16
+ return a;
21
17
  };
22
18
  /** `a / b / c / ...` */
23
- export const divide = (a, ...b) => {
24
- for (const n of b) {
25
- a /= n;
26
- }
27
- return a;
19
+ const divide = (a, ...b) => {
20
+ for (const n of b) a /= n;
21
+ return a;
28
22
  };
29
23
  /** `a ** b ** c ** ...` */
30
- export const power = (a, ...b) => {
31
- for (const n of b) {
32
- a = a ** n;
33
- }
34
- return a;
24
+ const power = (a, ...b) => {
25
+ for (const n of b) a = a ** n;
26
+ return a;
35
27
  };
36
28
  /** clamp a number value between two other values */
37
- export const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
29
+ const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
30
+ //#endregion
31
+ export { add, clamp, divide, multiply, power, substract };
@@ -1,63 +1,60 @@
1
- import { type Modify } from "../index.js";
1
+ /* @ts-self-types="./object.d.ts" */
2
+ import { Modify } from "../types.js";
3
+ //#region src/immutable/object.d.ts
2
4
  /**
3
- * Create a new subset object without the provided keys
4
- *
5
- * @example
6
- * ```ts
7
- * const newObject = omit({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
8
- * newObject // => { c: "baz" }
9
- * ```
10
- */
11
- export declare const omit: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Omit<O, K>;
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>;
12
14
  /**
13
- * Create a new subset object with only the provided keys
14
- *
15
- * @example
16
- * ```ts
17
- * const newObject = pick({ a:"foo", b:"bar", c: "baz" }, 'a', 'b')
18
- * newObject // => { a:"foo", b:"bar" }
19
- * ```
20
- */
21
- export declare const pick: <O extends object, K extends keyof O>(object: O, ...keys: K[]) => Pick<O, K>;
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>;
22
24
  /**
23
- * Get a single property value of an object by specifying a path to it.
24
- */
25
- export declare function get<O extends object, K extends keyof O>(obj: O, key: K): O[K];
26
- 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];
27
- 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];
28
- 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];
29
- 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];
30
- 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];
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];
31
33
  /**
32
- * Split object properties by keys into multiple object copies with a subset of selected properties.
33
- *
34
- * @param object original object
35
- * @param ...keys keys to pick from the source, or multiple arrays of keys *(for splitting into more than 2 objects)*
36
- * ```ts
37
- * (keyof object)[][] | (keyof object)[]
38
- * ```
39
- * @returns array of subset objects
40
- */
41
- export declare function split<T extends object, K extends keyof T>(object: T, ...keys: K[]): [Pick<T, K>, Omit<T, K>];
42
- 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>];
43
- 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>];
44
- 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>];
45
- 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[]]): [
46
- Pick<T, K1>,
47
- Pick<T, K2>,
48
- Pick<T, K3>,
49
- Pick<T, K4>,
50
- Pick<T, K5>,
51
- Omit<T, K1 | K2 | K3 | K4 | K5>
52
- ];
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>];
53
48
  /**
54
- * Merges multiple objects into a single one. Only the first level of properties is merged. An alternative to `{ ...a, ...b, ...c }`.
55
- * @param ...objects objects to merge
56
- * @example
57
- * const d = merge(a, b, c)
58
- */
59
- export declare function merge<A extends object, B extends object>(a: A, b: B): Modify<A, B>;
60
- export declare function merge<A extends object, B extends object, C extends object>(a: A, b: B, c: C): Modify<Modify<A, B>, C>;
61
- 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>;
62
- 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>;
63
- 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>;
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 };