es-toolkit 1.27.0 → 1.28.0-dev.908
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.
- package/CHANGELOG.md +14 -0
- package/dist/_chunk/{isWeakSet-D8h8bS.js → isWeakSet-CvIdTA.js} +5 -0
- package/dist/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
- package/dist/array/differenceBy.d.mts +10 -3
- package/dist/array/differenceBy.d.ts +10 -3
- package/dist/array/differenceWith.d.mts +11 -4
- package/dist/array/differenceWith.d.ts +11 -4
- package/dist/array/flatMap.d.mts +1 -1
- package/dist/array/flatMap.d.ts +1 -1
- package/dist/array/intersectionBy.d.mts +16 -5
- package/dist/array/intersectionBy.d.ts +16 -5
- package/dist/array/intersectionWith.d.mts +16 -4
- package/dist/array/intersectionWith.d.ts +16 -4
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/dropRightWhile.d.mts +2 -2
- package/dist/compat/array/dropRightWhile.d.ts +2 -2
- package/dist/compat/array/dropRightWhile.mjs +2 -0
- package/dist/compat/array/dropWhile.d.mts +2 -2
- package/dist/compat/array/dropWhile.d.ts +2 -2
- package/dist/compat/array/dropWhile.mjs +2 -0
- package/dist/compat/array/every.d.mts +6 -6
- package/dist/compat/array/every.d.ts +6 -6
- package/dist/compat/array/every.mjs +2 -0
- package/dist/compat/array/filter.d.mts +4 -4
- package/dist/compat/array/filter.d.ts +4 -4
- package/dist/compat/array/filter.mjs +2 -0
- package/dist/compat/array/find.d.mts +6 -6
- package/dist/compat/array/find.d.ts +6 -6
- package/dist/compat/array/find.mjs +2 -0
- package/dist/compat/array/findIndex.d.mts +3 -3
- package/dist/compat/array/findIndex.d.ts +3 -3
- package/dist/compat/array/findIndex.mjs +2 -0
- package/dist/compat/array/findLastIndex.d.mts +3 -3
- package/dist/compat/array/findLastIndex.d.ts +3 -3
- package/dist/compat/array/findLastIndex.mjs +2 -0
- package/dist/compat/array/some.d.mts +5 -5
- package/dist/compat/array/some.d.ts +5 -5
- package/dist/compat/array/some.mjs +2 -0
- package/dist/compat/array/uniqBy.d.mts +34 -13
- package/dist/compat/array/uniqBy.d.ts +34 -13
- package/dist/compat/array/uniqBy.mjs +3 -16
- package/dist/compat/function/debounce.d.mts +7 -5
- package/dist/compat/function/debounce.d.ts +7 -5
- package/dist/compat/function/throttle.d.mts +3 -4
- package/dist/compat/function/throttle.d.ts +3 -4
- package/dist/compat/function/throttle.mjs +6 -1
- package/dist/compat/index.d.mts +12 -2
- package/dist/compat/index.d.ts +12 -2
- package/dist/compat/index.js +179 -48
- package/dist/compat/index.mjs +10 -1
- package/dist/compat/math/add.d.mts +18 -0
- package/dist/compat/math/add.d.ts +18 -0
- package/dist/compat/math/add.mjs +5 -0
- package/dist/compat/object/assignIn.d.mts +103 -0
- package/dist/compat/object/assignIn.d.ts +103 -0
- package/dist/compat/object/assignIn.mjs +20 -0
- package/dist/compat/object/keysIn.d.mts +26 -0
- package/dist/compat/object/keysIn.d.ts +26 -0
- package/dist/compat/object/keysIn.mjs +53 -0
- package/dist/compat/predicate/isElement.d.mts +13 -0
- package/dist/compat/predicate/isElement.d.ts +13 -0
- package/dist/compat/predicate/isElement.mjs +8 -0
- package/dist/compat/string/toUpper.d.mts +20 -0
- package/dist/compat/string/toUpper.d.ts +20 -0
- package/dist/compat/string/toUpper.mjs +7 -0
- package/dist/compat/string/trim.mjs +1 -1
- package/dist/compat/string/trimEnd.mjs +1 -1
- package/dist/compat/string/trimStart.mjs +1 -1
- package/dist/compat/string/words.d.mts +15 -0
- package/dist/compat/string/words.d.ts +15 -0
- package/dist/compat/string/words.mjs +10 -0
- package/dist/compat/util/gt.d.mts +15 -0
- package/dist/compat/util/gt.d.ts +15 -0
- package/dist/compat/util/gt.mjs +10 -0
- package/dist/compat/util/gte.d.mts +15 -0
- package/dist/compat/util/gte.d.ts +15 -0
- package/dist/compat/util/gte.mjs +10 -0
- package/dist/compat/util/iteratee.d.mts +1 -1
- package/dist/compat/util/iteratee.d.ts +1 -1
- package/dist/compat/util/toArray.d.mts +15 -0
- package/dist/compat/util/toArray.d.ts +15 -0
- package/dist/compat/util/toArray.mjs +20 -0
- package/dist/function/debounce.d.mts +24 -22
- package/dist/function/debounce.d.ts +24 -22
- package/dist/function/index.d.mts +2 -2
- package/dist/function/index.d.ts +2 -2
- package/dist/function/partial.d.mts +533 -15
- package/dist/function/partial.d.ts +533 -15
- package/dist/function/partialRight.d.mts +610 -15
- package/dist/function/partialRight.d.ts +610 -15
- package/dist/function/throttle.d.mts +7 -5
- package/dist/function/throttle.d.ts +7 -5
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.mjs +1 -0
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +2 -1
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isBuffer.d.mts +21 -0
- package/dist/predicate/isBuffer.d.ts +21 -0
- package/dist/predicate/isBuffer.mjs +5 -0
- package/dist/string/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assigns the properties of a source object to a target object.
|
|
3
|
+
*
|
|
4
|
+
* This function merges the properties of the source object into the target object,
|
|
5
|
+
* including properties from the prototype chain. If a property in the source object
|
|
6
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
7
|
+
*
|
|
8
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
9
|
+
* @param {S} source - The source object whose properties will be assigned to the target object.
|
|
10
|
+
* @returns {O & S} The updated target object with properties from the source object assigned.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const target = { a: 1, b: 2 };
|
|
14
|
+
* const source = { b: 3, c: 4 };
|
|
15
|
+
* const result = assignIn(target, source);
|
|
16
|
+
* console.log(result); // Output: { a: 1, b: 3, c: 4 }
|
|
17
|
+
*/
|
|
18
|
+
declare function assignIn<O, S>(object: O, source: S): O & S;
|
|
19
|
+
/**
|
|
20
|
+
* Assigns the properties of two source objects to a target object.
|
|
21
|
+
*
|
|
22
|
+
* This function merges the properties of the source objects into the target object,
|
|
23
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
24
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
25
|
+
*
|
|
26
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
27
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
28
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
29
|
+
* @returns {O & S1 & S2} The updated target object with properties from the source objects assigned.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const target = { a: 1 };
|
|
33
|
+
* const source1 = { b: 2 };
|
|
34
|
+
* const source2 = { c: 3 };
|
|
35
|
+
* const result = assignIn(target, source1, source2);
|
|
36
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3 }
|
|
37
|
+
*/
|
|
38
|
+
declare function assignIn<O, S1, S2>(object: O, source1: S1, source2: S2): O & S1 & S2;
|
|
39
|
+
/**
|
|
40
|
+
* Assigns the properties of three source objects to a target object.
|
|
41
|
+
*
|
|
42
|
+
* This function merges the properties of the source objects into the target object,
|
|
43
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
44
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
45
|
+
*
|
|
46
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
47
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
48
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
49
|
+
* @param {S3} source3 - The third source object whose properties will be assigned to the target object.
|
|
50
|
+
* @returns {O & S1 & S2 & S3} The updated target object with properties from the source objects assigned.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const target = { a: 1 };
|
|
54
|
+
* const source1 = { b: 2 };
|
|
55
|
+
* const source2 = { c: 3 };
|
|
56
|
+
* const source3 = { d: 4 };
|
|
57
|
+
* const result = assignIn(target, source1, source2, source3);
|
|
58
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3, d: 4 }
|
|
59
|
+
*/
|
|
60
|
+
declare function assignIn<O, S1, S2, S3>(object: O, source1: S1, source2: S2, source3: S3): O & S1 & S2 & S3;
|
|
61
|
+
/**
|
|
62
|
+
* Assigns the properties of four source objects to a target object.
|
|
63
|
+
*
|
|
64
|
+
* This function merges the properties of the source objects into the target object,
|
|
65
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
66
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
67
|
+
*
|
|
68
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
69
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
70
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
71
|
+
* @param {S3} source3 - The third source object whose properties will be assigned to the target object.
|
|
72
|
+
* @param {S4} source4 - The fourth source object whose properties will be assigned to the target object.
|
|
73
|
+
* @returns {O & S1 & S2 & S3} The updated target object with properties from the source objects assigned.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const target = { a: 1 };
|
|
77
|
+
* const source1 = { b: 2 };
|
|
78
|
+
* const source2 = { c: 3 };
|
|
79
|
+
* const source3 = { d: 4 };
|
|
80
|
+
* const source4 = { e: 5 };
|
|
81
|
+
* const result = assignIn(target, source1, source2, source3, source4);
|
|
82
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3, d: 4, e: 5 }
|
|
83
|
+
*/
|
|
84
|
+
declare function assignIn<O, S1, S2, S3, S4>(object: O, source1: S1, source2: S2, source3: S3, source4: S4): O & S1 & S2 & S3;
|
|
85
|
+
/**
|
|
86
|
+
* Assigns properties from multiple source objects to a target object.
|
|
87
|
+
*
|
|
88
|
+
* This function merges the properties of the source objects into the target object,
|
|
89
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
90
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
91
|
+
*
|
|
92
|
+
* @param {any} object - The target object to which properties will be assigned.
|
|
93
|
+
* @param {...any[]} sources - The source objects whose properties will be assigned to the target object.
|
|
94
|
+
* @returns {any} The updated target object with properties from the source objects assigned.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const target = { a: 1 };
|
|
98
|
+
* const result = assignIn(target, { b: 2 }, { c: 3 }, { a: 4 });
|
|
99
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3 }
|
|
100
|
+
*/
|
|
101
|
+
declare function assignIn(object: any, ...sources: any[]): any;
|
|
102
|
+
|
|
103
|
+
export { assignIn };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assigns the properties of a source object to a target object.
|
|
3
|
+
*
|
|
4
|
+
* This function merges the properties of the source object into the target object,
|
|
5
|
+
* including properties from the prototype chain. If a property in the source object
|
|
6
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
7
|
+
*
|
|
8
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
9
|
+
* @param {S} source - The source object whose properties will be assigned to the target object.
|
|
10
|
+
* @returns {O & S} The updated target object with properties from the source object assigned.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const target = { a: 1, b: 2 };
|
|
14
|
+
* const source = { b: 3, c: 4 };
|
|
15
|
+
* const result = assignIn(target, source);
|
|
16
|
+
* console.log(result); // Output: { a: 1, b: 3, c: 4 }
|
|
17
|
+
*/
|
|
18
|
+
declare function assignIn<O, S>(object: O, source: S): O & S;
|
|
19
|
+
/**
|
|
20
|
+
* Assigns the properties of two source objects to a target object.
|
|
21
|
+
*
|
|
22
|
+
* This function merges the properties of the source objects into the target object,
|
|
23
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
24
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
25
|
+
*
|
|
26
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
27
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
28
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
29
|
+
* @returns {O & S1 & S2} The updated target object with properties from the source objects assigned.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const target = { a: 1 };
|
|
33
|
+
* const source1 = { b: 2 };
|
|
34
|
+
* const source2 = { c: 3 };
|
|
35
|
+
* const result = assignIn(target, source1, source2);
|
|
36
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3 }
|
|
37
|
+
*/
|
|
38
|
+
declare function assignIn<O, S1, S2>(object: O, source1: S1, source2: S2): O & S1 & S2;
|
|
39
|
+
/**
|
|
40
|
+
* Assigns the properties of three source objects to a target object.
|
|
41
|
+
*
|
|
42
|
+
* This function merges the properties of the source objects into the target object,
|
|
43
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
44
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
45
|
+
*
|
|
46
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
47
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
48
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
49
|
+
* @param {S3} source3 - The third source object whose properties will be assigned to the target object.
|
|
50
|
+
* @returns {O & S1 & S2 & S3} The updated target object with properties from the source objects assigned.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const target = { a: 1 };
|
|
54
|
+
* const source1 = { b: 2 };
|
|
55
|
+
* const source2 = { c: 3 };
|
|
56
|
+
* const source3 = { d: 4 };
|
|
57
|
+
* const result = assignIn(target, source1, source2, source3);
|
|
58
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3, d: 4 }
|
|
59
|
+
*/
|
|
60
|
+
declare function assignIn<O, S1, S2, S3>(object: O, source1: S1, source2: S2, source3: S3): O & S1 & S2 & S3;
|
|
61
|
+
/**
|
|
62
|
+
* Assigns the properties of four source objects to a target object.
|
|
63
|
+
*
|
|
64
|
+
* This function merges the properties of the source objects into the target object,
|
|
65
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
66
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
67
|
+
*
|
|
68
|
+
* @param {O} object - The target object to which properties will be assigned.
|
|
69
|
+
* @param {S1} source1 - The first source object whose properties will be assigned to the target object.
|
|
70
|
+
* @param {S2} source2 - The second source object whose properties will be assigned to the target object.
|
|
71
|
+
* @param {S3} source3 - The third source object whose properties will be assigned to the target object.
|
|
72
|
+
* @param {S4} source4 - The fourth source object whose properties will be assigned to the target object.
|
|
73
|
+
* @returns {O & S1 & S2 & S3} The updated target object with properties from the source objects assigned.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const target = { a: 1 };
|
|
77
|
+
* const source1 = { b: 2 };
|
|
78
|
+
* const source2 = { c: 3 };
|
|
79
|
+
* const source3 = { d: 4 };
|
|
80
|
+
* const source4 = { e: 5 };
|
|
81
|
+
* const result = assignIn(target, source1, source2, source3, source4);
|
|
82
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3, d: 4, e: 5 }
|
|
83
|
+
*/
|
|
84
|
+
declare function assignIn<O, S1, S2, S3, S4>(object: O, source1: S1, source2: S2, source3: S3, source4: S4): O & S1 & S2 & S3;
|
|
85
|
+
/**
|
|
86
|
+
* Assigns properties from multiple source objects to a target object.
|
|
87
|
+
*
|
|
88
|
+
* This function merges the properties of the source objects into the target object,
|
|
89
|
+
* including properties from the prototype chain. If a property in the source objects
|
|
90
|
+
* is equal to the corresponding property in the target object, it will not be overwritten.
|
|
91
|
+
*
|
|
92
|
+
* @param {any} object - The target object to which properties will be assigned.
|
|
93
|
+
* @param {...any[]} sources - The source objects whose properties will be assigned to the target object.
|
|
94
|
+
* @returns {any} The updated target object with properties from the source objects assigned.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const target = { a: 1 };
|
|
98
|
+
* const result = assignIn(target, { b: 2 }, { c: 3 }, { a: 4 });
|
|
99
|
+
* console.log(result); // Output: { a: 1, b: 2, c: 3 }
|
|
100
|
+
*/
|
|
101
|
+
declare function assignIn(object: any, ...sources: any[]): any;
|
|
102
|
+
|
|
103
|
+
export { assignIn };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { keysIn } from './keysIn.mjs';
|
|
2
|
+
import { eq } from '../util/eq.mjs';
|
|
3
|
+
|
|
4
|
+
function assignIn(object, ...sources) {
|
|
5
|
+
for (let i = 0; i < sources.length; i++) {
|
|
6
|
+
assignInImpl(object, sources[i]);
|
|
7
|
+
}
|
|
8
|
+
return object;
|
|
9
|
+
}
|
|
10
|
+
function assignInImpl(object, source) {
|
|
11
|
+
const keys = keysIn(source);
|
|
12
|
+
for (let i = 0; i < keys.length; i++) {
|
|
13
|
+
const key = keys[i];
|
|
14
|
+
if (!eq(object[key], source[key])) {
|
|
15
|
+
object[key] = source[key];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { assignIn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype.
|
|
3
|
+
*
|
|
4
|
+
* - If the value is not an object, it is converted to an object.
|
|
5
|
+
* - Array-like objects are treated like arrays.
|
|
6
|
+
* - Sparse arrays with some missing indices are treated like dense arrays.
|
|
7
|
+
* - If the value is `null` or `undefined`, an empty array is returned.
|
|
8
|
+
* - When handling prototype objects, the `constructor` property is excluded from the results.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} [object] - The object to inspect for keys.
|
|
11
|
+
* @returns {string[]} An array of string keys from the object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const obj = { a: 1, b: 2 };
|
|
15
|
+
* console.log(keysIn(obj)); // ['a', 'b']
|
|
16
|
+
*
|
|
17
|
+
* const arr = [1, 2, 3];
|
|
18
|
+
* console.log(keysIn(arr)); // ['0', '1', '2']
|
|
19
|
+
*
|
|
20
|
+
* function Foo() {}
|
|
21
|
+
* Foo.prototype.a = 1;
|
|
22
|
+
* console.log(keysIn(new Foo())); // ['a']
|
|
23
|
+
*/
|
|
24
|
+
declare function keysIn(object?: unknown): string[];
|
|
25
|
+
|
|
26
|
+
export { keysIn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function retrieves the names of string-keyed properties from an object, including those inherited from its prototype.
|
|
3
|
+
*
|
|
4
|
+
* - If the value is not an object, it is converted to an object.
|
|
5
|
+
* - Array-like objects are treated like arrays.
|
|
6
|
+
* - Sparse arrays with some missing indices are treated like dense arrays.
|
|
7
|
+
* - If the value is `null` or `undefined`, an empty array is returned.
|
|
8
|
+
* - When handling prototype objects, the `constructor` property is excluded from the results.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} [object] - The object to inspect for keys.
|
|
11
|
+
* @returns {string[]} An array of string keys from the object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const obj = { a: 1, b: 2 };
|
|
15
|
+
* console.log(keysIn(obj)); // ['a', 'b']
|
|
16
|
+
*
|
|
17
|
+
* const arr = [1, 2, 3];
|
|
18
|
+
* console.log(keysIn(arr)); // ['0', '1', '2']
|
|
19
|
+
*
|
|
20
|
+
* function Foo() {}
|
|
21
|
+
* Foo.prototype.a = 1;
|
|
22
|
+
* console.log(keysIn(new Foo())); // ['a']
|
|
23
|
+
*/
|
|
24
|
+
declare function keysIn(object?: unknown): string[];
|
|
25
|
+
|
|
26
|
+
export { keysIn };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isBuffer } from '../../predicate/isBuffer.mjs';
|
|
2
|
+
import { isPrototype } from '../_internal/isPrototype.mjs';
|
|
3
|
+
import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
4
|
+
import { isTypedArray } from '../predicate/isTypedArray.mjs';
|
|
5
|
+
import { times } from '../util/times.mjs';
|
|
6
|
+
|
|
7
|
+
function keysIn(object) {
|
|
8
|
+
if (object == null) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
switch (typeof object) {
|
|
12
|
+
case 'object':
|
|
13
|
+
case 'function': {
|
|
14
|
+
if (isArrayLike(object)) {
|
|
15
|
+
return arrayLikeKeysIn(object);
|
|
16
|
+
}
|
|
17
|
+
if (isPrototype(object)) {
|
|
18
|
+
return prototypeKeysIn(object);
|
|
19
|
+
}
|
|
20
|
+
return keysInImpl(object);
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
return keysInImpl(Object(object));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function keysInImpl(object) {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (const key in object) {
|
|
30
|
+
result.push(key);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function prototypeKeysIn(object) {
|
|
35
|
+
const keys = keysInImpl(object);
|
|
36
|
+
return keys.filter(key => key !== 'constructor');
|
|
37
|
+
}
|
|
38
|
+
function arrayLikeKeysIn(object) {
|
|
39
|
+
const indices = times(object.length, index => `${index}`);
|
|
40
|
+
const filteredKeys = new Set(indices);
|
|
41
|
+
if (isBuffer(object)) {
|
|
42
|
+
filteredKeys.add('offset');
|
|
43
|
+
filteredKeys.add('parent');
|
|
44
|
+
}
|
|
45
|
+
if (isTypedArray(object)) {
|
|
46
|
+
filteredKeys.add('buffer');
|
|
47
|
+
filteredKeys.add('byteLength');
|
|
48
|
+
filteredKeys.add('byteOffset');
|
|
49
|
+
}
|
|
50
|
+
return [...indices, ...keysInImpl(object).filter(key => !filteredKeys.has(key))];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { keysIn };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if `value` is likely a DOM element.
|
|
3
|
+
*
|
|
4
|
+
* @param {any} value The value to check.
|
|
5
|
+
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* console.log(isElement(document.body)); // true
|
|
9
|
+
* console.log(isElement('<body>')); // false
|
|
10
|
+
*/
|
|
11
|
+
declare function isElement(value: any): boolean;
|
|
12
|
+
|
|
13
|
+
export { isElement };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if `value` is likely a DOM element.
|
|
3
|
+
*
|
|
4
|
+
* @param {any} value The value to check.
|
|
5
|
+
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* console.log(isElement(document.body)); // true
|
|
9
|
+
* console.log(isElement('<body>')); // false
|
|
10
|
+
*/
|
|
11
|
+
declare function isElement(value: any): boolean;
|
|
12
|
+
|
|
13
|
+
export { isElement };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts `string`, as a whole, to upper case just like
|
|
3
|
+
* [String#toUpperCase](https://mdn.io/toUpperCase).
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} [value=''] The value to convert.
|
|
6
|
+
* @returns {string} Returns the upper cased string.
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* toUpper('--foo-bar--');
|
|
10
|
+
* // => '--FOO-BAR--'
|
|
11
|
+
*
|
|
12
|
+
* toUpper(null);
|
|
13
|
+
* // => ''
|
|
14
|
+
*
|
|
15
|
+
* toUpper([1, 2, 3]);
|
|
16
|
+
* // => '1,2,3'
|
|
17
|
+
*/
|
|
18
|
+
declare function toUpper(value?: unknown): string;
|
|
19
|
+
|
|
20
|
+
export { toUpper };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts `string`, as a whole, to upper case just like
|
|
3
|
+
* [String#toUpperCase](https://mdn.io/toUpperCase).
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} [value=''] The value to convert.
|
|
6
|
+
* @returns {string} Returns the upper cased string.
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* toUpper('--foo-bar--');
|
|
10
|
+
* // => '--FOO-BAR--'
|
|
11
|
+
*
|
|
12
|
+
* toUpper(null);
|
|
13
|
+
* // => ''
|
|
14
|
+
*
|
|
15
|
+
* toUpper([1, 2, 3]);
|
|
16
|
+
* // => '1,2,3'
|
|
17
|
+
*/
|
|
18
|
+
declare function toUpper(value?: unknown): string;
|
|
19
|
+
|
|
20
|
+
export { toUpper };
|
|
@@ -13,7 +13,7 @@ function trim(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trim$1(str, chars.
|
|
16
|
+
return trim$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trim$1(str, chars.toString().split(''));
|
|
@@ -13,7 +13,7 @@ function trimEnd(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trimEnd$1(str, chars.
|
|
16
|
+
return trimEnd$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trimEnd$1(str, chars.toString().split(''));
|
|
@@ -13,7 +13,7 @@ function trimStart(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trimStart$1(str, chars.
|
|
16
|
+
return trimStart$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trimStart$1(str, chars.toString().split(''));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits `string` into an array of its words.
|
|
3
|
+
*
|
|
4
|
+
* @param {string | object} str - The string or object that is to be split into words.
|
|
5
|
+
* @param {RegExp | string} [pattern] - The pattern to match words.
|
|
6
|
+
* @returns {string[]} - Returns the words of `string`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const wordsArray1 = words('fred, barney, & pebbles');
|
|
10
|
+
* // => ['fred', 'barney', 'pebbles']
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
declare function words(str?: string | object, pattern?: RegExp | string): string[];
|
|
14
|
+
|
|
15
|
+
export { words };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits `string` into an array of its words.
|
|
3
|
+
*
|
|
4
|
+
* @param {string | object} str - The string or object that is to be split into words.
|
|
5
|
+
* @param {RegExp | string} [pattern] - The pattern to match words.
|
|
6
|
+
* @returns {string[]} - Returns the words of `string`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const wordsArray1 = words('fred, barney, & pebbles');
|
|
10
|
+
* // => ['fred', 'barney', 'pebbles']
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
declare function words(str?: string | object, pattern?: RegExp | string): string[];
|
|
14
|
+
|
|
15
|
+
export { words };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CASE_SPLIT_PATTERN } from '../../string/words.mjs';
|
|
2
|
+
import { toString } from '../util/toString.mjs';
|
|
3
|
+
|
|
4
|
+
function words(str, pattern = CASE_SPLIT_PATTERN) {
|
|
5
|
+
const input = toString(str);
|
|
6
|
+
const words = Array.from(input.match(pattern) ?? []);
|
|
7
|
+
return words.filter(x => x !== '');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { words };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if value is greater than other.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value The value to compare.
|
|
5
|
+
* @param {unknown} other The other value to compare.
|
|
6
|
+
* @returns {boolean} Returns `true` if value is greater than other, else `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* gt(3, 1); // true
|
|
10
|
+
* gt(3, 3); // false
|
|
11
|
+
* gt(1, 3); // false
|
|
12
|
+
*/
|
|
13
|
+
declare function gt(value: unknown, other: unknown): boolean;
|
|
14
|
+
|
|
15
|
+
export { gt };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if value is greater than other.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value The value to compare.
|
|
5
|
+
* @param {unknown} other The other value to compare.
|
|
6
|
+
* @returns {boolean} Returns `true` if value is greater than other, else `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* gt(3, 1); // true
|
|
10
|
+
* gt(3, 3); // false
|
|
11
|
+
* gt(1, 3); // false
|
|
12
|
+
*/
|
|
13
|
+
declare function gt(value: unknown, other: unknown): boolean;
|
|
14
|
+
|
|
15
|
+
export { gt };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if value is greater than or equal to other.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value The value to compare.
|
|
5
|
+
* @param {unknown} other The other value to compare.
|
|
6
|
+
* @returns {boolean} Returns `true` if value is greater than or equal to other, else `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* gte(3, 1); // => true
|
|
10
|
+
* gte(3, 3); // => true
|
|
11
|
+
* gte(1, 3); // => false
|
|
12
|
+
*/
|
|
13
|
+
declare function gte(value: unknown, other: unknown): boolean;
|
|
14
|
+
|
|
15
|
+
export { gte };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if value is greater than or equal to other.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value The value to compare.
|
|
5
|
+
* @param {unknown} other The other value to compare.
|
|
6
|
+
* @returns {boolean} Returns `true` if value is greater than or equal to other, else `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* gte(3, 1); // => true
|
|
10
|
+
* gte(3, 3); // => true
|
|
11
|
+
* gte(1, 3); // => false
|
|
12
|
+
*/
|
|
13
|
+
declare function gte(value: unknown, other: unknown): boolean;
|
|
14
|
+
|
|
15
|
+
export { gte };
|
|
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
|
|
|
39
39
|
* const func = iteratee(['a', 1]);
|
|
40
40
|
* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
|
|
41
41
|
*/
|
|
42
|
-
declare function iteratee(value
|
|
42
|
+
declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
|
|
43
43
|
|
|
44
44
|
export { iteratee };
|
|
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
|
|
|
39
39
|
* const func = iteratee(['a', 1]);
|
|
40
40
|
* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
|
|
41
41
|
*/
|
|
42
|
-
declare function iteratee(value
|
|
42
|
+
declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
|
|
43
43
|
|
|
44
44
|
export { iteratee };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a value to an array.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value - The value to convert.
|
|
5
|
+
* @returns {any[]} Returns the converted array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
|
|
9
|
+
* toArray('abc') // => returns ['a', 'b', 'c']
|
|
10
|
+
* toArray(1) // => returns []
|
|
11
|
+
* toArray(null) // => returns []
|
|
12
|
+
*/
|
|
13
|
+
declare function toArray(value?: unknown): any[];
|
|
14
|
+
|
|
15
|
+
export { toArray };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a value to an array.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value - The value to convert.
|
|
5
|
+
* @returns {any[]} Returns the converted array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
|
|
9
|
+
* toArray('abc') // => returns ['a', 'b', 'c']
|
|
10
|
+
* toArray(1) // => returns []
|
|
11
|
+
* toArray(null) // => returns []
|
|
12
|
+
*/
|
|
13
|
+
declare function toArray(value?: unknown): any[];
|
|
14
|
+
|
|
15
|
+
export { toArray };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
2
|
+
import { isMap } from '../predicate/isMap.mjs';
|
|
3
|
+
|
|
4
|
+
function toArray(value) {
|
|
5
|
+
if (value == null) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
if (isArrayLike(value) || isMap(value)) {
|
|
9
|
+
return Array.from(value);
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === 'string') {
|
|
12
|
+
return value.split('');
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'object') {
|
|
15
|
+
return Object.values(value);
|
|
16
|
+
}
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { toArray };
|