es-toolkit 1.27.0-dev.885 → 1.27.0-dev.887
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/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/index.js +16 -0
- package/package.json +1 -1
|
@@ -47,7 +47,7 @@ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propert
|
|
|
47
47
|
*
|
|
48
48
|
* @template T - The type of elements in the array.
|
|
49
49
|
* @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {PropertyKey} propertyToDrop - The name of the property to match for dropping elements.
|
|
51
51
|
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
@@ -55,6 +55,6 @@ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propert
|
|
|
55
55
|
* const result = dropRightWhile(array, 'isActive');
|
|
56
56
|
* result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
|
|
57
57
|
*/
|
|
58
|
-
declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop:
|
|
58
|
+
declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: PropertyKey): T[];
|
|
59
59
|
|
|
60
60
|
export { dropRightWhile };
|
|
@@ -47,7 +47,7 @@ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propert
|
|
|
47
47
|
*
|
|
48
48
|
* @template T - The type of elements in the array.
|
|
49
49
|
* @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {PropertyKey} propertyToDrop - The name of the property to match for dropping elements.
|
|
51
51
|
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
@@ -55,6 +55,6 @@ declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propert
|
|
|
55
55
|
* const result = dropRightWhile(array, 'isActive');
|
|
56
56
|
* result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
|
|
57
57
|
*/
|
|
58
|
-
declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop:
|
|
58
|
+
declare function dropRightWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: PropertyKey): T[];
|
|
59
59
|
|
|
60
60
|
export { dropRightWhile };
|
|
@@ -47,7 +47,7 @@ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDr
|
|
|
47
47
|
*
|
|
48
48
|
* @template T - The type of elements in the array.
|
|
49
49
|
* @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {PropertyKey} propertyToDrop - The name of the property to match for dropping elements.
|
|
51
51
|
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
@@ -55,6 +55,6 @@ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDr
|
|
|
55
55
|
* const result = dropWhile(array, 'isActive');
|
|
56
56
|
* result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
|
|
57
57
|
*/
|
|
58
|
-
declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop:
|
|
58
|
+
declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: PropertyKey): T[];
|
|
59
59
|
|
|
60
60
|
export { dropWhile };
|
|
@@ -47,7 +47,7 @@ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDr
|
|
|
47
47
|
*
|
|
48
48
|
* @template T - The type of elements in the array.
|
|
49
49
|
* @param {ArrayLike<T> | null | undefined} arr - The array from which to drop elements.
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {PropertyKey} propertyToDrop - The name of the property to match for dropping elements.
|
|
51
51
|
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
@@ -55,6 +55,6 @@ declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDr
|
|
|
55
55
|
* const result = dropWhile(array, 'isActive');
|
|
56
56
|
* result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.
|
|
57
57
|
*/
|
|
58
|
-
declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop:
|
|
58
|
+
declare function dropWhile<T>(arr: ArrayLike<T> | null | undefined, propertyToDrop: PropertyKey): T[];
|
|
59
59
|
|
|
60
60
|
export { dropWhile };
|
|
@@ -61,11 +61,11 @@ declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatch: Parti
|
|
|
61
61
|
*/
|
|
62
62
|
declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown]): boolean;
|
|
63
63
|
/**
|
|
64
|
-
* Checks if every item in an array has a specific property, where the property name is provided as a
|
|
64
|
+
* Checks if every item in an array has a specific property, where the property name is provided as a PropertyKey.
|
|
65
65
|
*
|
|
66
66
|
* @template T
|
|
67
67
|
* @param {ArrayLike<T> | null | undefined} arr - The array to check through.
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
69
69
|
* @returns {boolean} - `true` if every item has the specified property, or `false` if at least one item does not match.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
@@ -74,7 +74,7 @@ declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatchPropert
|
|
|
74
74
|
* const result = every(items, 'name');
|
|
75
75
|
* console.log(result); // true
|
|
76
76
|
*/
|
|
77
|
-
declare function every<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
77
|
+
declare function every<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Checks if every item in an object matches the given predicate function.
|
|
80
80
|
*
|
|
@@ -121,11 +121,11 @@ declare function every<T extends Record<string, unknown>>(object: T | null | und
|
|
|
121
121
|
*/
|
|
122
122
|
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): boolean;
|
|
123
123
|
/**
|
|
124
|
-
* Checks if every item in an object has a specific property, where the property name is provided as a
|
|
124
|
+
* Checks if every item in an object has a specific property, where the property name is provided as a PropertyKey.
|
|
125
125
|
*
|
|
126
126
|
* @template T
|
|
127
127
|
* @param {T | null | undefined} object - The object to check through.
|
|
128
|
-
* @param {
|
|
128
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
129
129
|
* @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.
|
|
130
130
|
*
|
|
131
131
|
* @example
|
|
@@ -134,6 +134,6 @@ declare function every<T extends Record<string, unknown>>(object: T | null | und
|
|
|
134
134
|
* const result = every(obj, 'name');
|
|
135
135
|
* console.log(result); // true
|
|
136
136
|
*/
|
|
137
|
-
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
137
|
+
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
138
138
|
|
|
139
139
|
export { every };
|
|
@@ -61,11 +61,11 @@ declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatch: Parti
|
|
|
61
61
|
*/
|
|
62
62
|
declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown]): boolean;
|
|
63
63
|
/**
|
|
64
|
-
* Checks if every item in an array has a specific property, where the property name is provided as a
|
|
64
|
+
* Checks if every item in an array has a specific property, where the property name is provided as a PropertyKey.
|
|
65
65
|
*
|
|
66
66
|
* @template T
|
|
67
67
|
* @param {ArrayLike<T> | null | undefined} arr - The array to check through.
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
69
69
|
* @returns {boolean} - `true` if every item has the specified property, or `false` if at least one item does not match.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
@@ -74,7 +74,7 @@ declare function every<T>(arr: ArrayLike<T> | null | undefined, doesMatchPropert
|
|
|
74
74
|
* const result = every(items, 'name');
|
|
75
75
|
* console.log(result); // true
|
|
76
76
|
*/
|
|
77
|
-
declare function every<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
77
|
+
declare function every<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Checks if every item in an object matches the given predicate function.
|
|
80
80
|
*
|
|
@@ -121,11 +121,11 @@ declare function every<T extends Record<string, unknown>>(object: T | null | und
|
|
|
121
121
|
*/
|
|
122
122
|
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): boolean;
|
|
123
123
|
/**
|
|
124
|
-
* Checks if every item in an object has a specific property, where the property name is provided as a
|
|
124
|
+
* Checks if every item in an object has a specific property, where the property name is provided as a PropertyKey.
|
|
125
125
|
*
|
|
126
126
|
* @template T
|
|
127
127
|
* @param {T | null | undefined} object - The object to check through.
|
|
128
|
-
* @param {
|
|
128
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
129
129
|
* @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.
|
|
130
130
|
*
|
|
131
131
|
* @example
|
|
@@ -134,6 +134,6 @@ declare function every<T extends Record<string, unknown>>(object: T | null | und
|
|
|
134
134
|
* const result = every(obj, 'name');
|
|
135
135
|
* console.log(result); // true
|
|
136
136
|
*/
|
|
137
|
-
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
137
|
+
declare function every<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
138
138
|
|
|
139
139
|
export { every };
|
|
@@ -44,7 +44,7 @@ declare function filter<T>(arr: ArrayLike<T> | null | undefined, doesMatchProper
|
|
|
44
44
|
*
|
|
45
45
|
* @template T
|
|
46
46
|
* @param {ArrayLike<T> | null | undefined} arr - The array to iterate over.
|
|
47
|
-
* @param {
|
|
47
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
48
48
|
* @returns {T[]} - Returns a new array of elements that match the given property name.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
@@ -52,7 +52,7 @@ declare function filter<T>(arr: ArrayLike<T> | null | undefined, doesMatchProper
|
|
|
52
52
|
* filter(arr, 'name');
|
|
53
53
|
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
54
54
|
*/
|
|
55
|
-
declare function filter<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
55
|
+
declare function filter<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): T[];
|
|
56
56
|
/**
|
|
57
57
|
* Filters items from a object and returns an array of elements that match the given predicate function.
|
|
58
58
|
*
|
|
@@ -104,7 +104,7 @@ declare function filter<T extends Record<string, unknown>>(object: T | null | un
|
|
|
104
104
|
*
|
|
105
105
|
* @template T
|
|
106
106
|
* @param {T | null | undefined} object - The object to iterate over.
|
|
107
|
-
* @param {
|
|
107
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
108
108
|
* @returns {T[]} - Returns a new array of elements that match the given property name.
|
|
109
109
|
*
|
|
110
110
|
* @example
|
|
@@ -112,6 +112,6 @@ declare function filter<T extends Record<string, unknown>>(object: T | null | un
|
|
|
112
112
|
* filter(obj, 'name');
|
|
113
113
|
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
114
114
|
*/
|
|
115
|
-
declare function filter<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
115
|
+
declare function filter<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): T[];
|
|
116
116
|
|
|
117
117
|
export { filter };
|
|
@@ -44,7 +44,7 @@ declare function filter<T>(arr: ArrayLike<T> | null | undefined, doesMatchProper
|
|
|
44
44
|
*
|
|
45
45
|
* @template T
|
|
46
46
|
* @param {ArrayLike<T> | null | undefined} arr - The array to iterate over.
|
|
47
|
-
* @param {
|
|
47
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
48
48
|
* @returns {T[]} - Returns a new array of elements that match the given property name.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
@@ -52,7 +52,7 @@ declare function filter<T>(arr: ArrayLike<T> | null | undefined, doesMatchProper
|
|
|
52
52
|
* filter(arr, 'name');
|
|
53
53
|
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
54
54
|
*/
|
|
55
|
-
declare function filter<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
55
|
+
declare function filter<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): T[];
|
|
56
56
|
/**
|
|
57
57
|
* Filters items from a object and returns an array of elements that match the given predicate function.
|
|
58
58
|
*
|
|
@@ -104,7 +104,7 @@ declare function filter<T extends Record<string, unknown>>(object: T | null | un
|
|
|
104
104
|
*
|
|
105
105
|
* @template T
|
|
106
106
|
* @param {T | null | undefined} object - The object to iterate over.
|
|
107
|
-
* @param {
|
|
107
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
108
108
|
* @returns {T[]} - Returns a new array of elements that match the given property name.
|
|
109
109
|
*
|
|
110
110
|
* @example
|
|
@@ -112,6 +112,6 @@ declare function filter<T extends Record<string, unknown>>(object: T | null | un
|
|
|
112
112
|
* filter(obj, 'name');
|
|
113
113
|
* // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
114
114
|
*/
|
|
115
|
-
declare function filter<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
115
|
+
declare function filter<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): T[];
|
|
116
116
|
|
|
117
117
|
export { filter };
|
|
@@ -33,6 +33,8 @@ function filter(source, predicate) {
|
|
|
33
33
|
? collection.filter(matchesProperty(predicate[0], predicate[1]))
|
|
34
34
|
: collection.filter(matches(predicate));
|
|
35
35
|
}
|
|
36
|
+
case 'symbol':
|
|
37
|
+
case 'number':
|
|
36
38
|
case 'string': {
|
|
37
39
|
return collection.filter(property(predicate));
|
|
38
40
|
}
|
|
@@ -44,11 +44,11 @@ declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatch: Partia
|
|
|
44
44
|
*/
|
|
45
45
|
declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown]): T | undefined;
|
|
46
46
|
/**
|
|
47
|
-
* Finds the first item in an array that has a specific property, where the property name is provided as a
|
|
47
|
+
* Finds the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
48
48
|
*
|
|
49
49
|
* @template T
|
|
50
50
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
52
52
|
* @returns {T | undefined} - The first item that has the specified property, or `undefined` if no match is found.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
@@ -57,7 +57,7 @@ declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty
|
|
|
57
57
|
* const result = find(items, 'name');
|
|
58
58
|
* console.log(result); // { id: 1, name: 'Alice' }
|
|
59
59
|
*/
|
|
60
|
-
declare function find<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
60
|
+
declare function find<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): T | undefined;
|
|
61
61
|
/**
|
|
62
62
|
* Finds the first item in an object that matches the given predicate function.
|
|
63
63
|
*
|
|
@@ -104,11 +104,11 @@ declare function find<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
104
104
|
*/
|
|
105
105
|
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): T | undefined;
|
|
106
106
|
/**
|
|
107
|
-
* Finds the first item in an object that has a specific property, where the property name is provided as a
|
|
107
|
+
* Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
|
|
108
108
|
*
|
|
109
109
|
* @template T
|
|
110
110
|
* @param {T | null | undefined} object - The object to search through.
|
|
111
|
-
* @param {
|
|
111
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
112
112
|
* @returns {T | undefined} - The first property value that has the specified property, or `undefined` if no match is found.
|
|
113
113
|
*
|
|
114
114
|
* @example
|
|
@@ -117,6 +117,6 @@ declare function find<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
117
117
|
* const result = find(obj, 'name');
|
|
118
118
|
* console.log(result); // { id: 1, name: 'Alice' }
|
|
119
119
|
*/
|
|
120
|
-
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
120
|
+
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): T | undefined;
|
|
121
121
|
|
|
122
122
|
export { find };
|
|
@@ -44,11 +44,11 @@ declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatch: Partia
|
|
|
44
44
|
*/
|
|
45
45
|
declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown]): T | undefined;
|
|
46
46
|
/**
|
|
47
|
-
* Finds the first item in an array that has a specific property, where the property name is provided as a
|
|
47
|
+
* Finds the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
48
48
|
*
|
|
49
49
|
* @template T
|
|
50
50
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
52
52
|
* @returns {T | undefined} - The first item that has the specified property, or `undefined` if no match is found.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
@@ -57,7 +57,7 @@ declare function find<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty
|
|
|
57
57
|
* const result = find(items, 'name');
|
|
58
58
|
* console.log(result); // { id: 1, name: 'Alice' }
|
|
59
59
|
*/
|
|
60
|
-
declare function find<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
60
|
+
declare function find<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): T | undefined;
|
|
61
61
|
/**
|
|
62
62
|
* Finds the first item in an object that matches the given predicate function.
|
|
63
63
|
*
|
|
@@ -104,11 +104,11 @@ declare function find<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
104
104
|
*/
|
|
105
105
|
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): T | undefined;
|
|
106
106
|
/**
|
|
107
|
-
* Finds the first item in an object that has a specific property, where the property name is provided as a
|
|
107
|
+
* Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
|
|
108
108
|
*
|
|
109
109
|
* @template T
|
|
110
110
|
* @param {T | null | undefined} object - The object to search through.
|
|
111
|
-
* @param {
|
|
111
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
112
112
|
* @returns {T | undefined} - The first property value that has the specified property, or `undefined` if no match is found.
|
|
113
113
|
*
|
|
114
114
|
* @example
|
|
@@ -117,6 +117,6 @@ declare function find<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
117
117
|
* const result = find(obj, 'name');
|
|
118
118
|
* console.log(result); // { id: 1, name: 'Alice' }
|
|
119
119
|
*/
|
|
120
|
-
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
120
|
+
declare function find<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): T | undefined;
|
|
121
121
|
|
|
122
122
|
export { find };
|
|
@@ -47,11 +47,11 @@ declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatch: P
|
|
|
47
47
|
*/
|
|
48
48
|
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown], fromIndex?: number): number;
|
|
49
49
|
/**
|
|
50
|
-
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a
|
|
50
|
+
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
51
51
|
*
|
|
52
52
|
* @template T
|
|
53
53
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
55
55
|
* @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.
|
|
56
56
|
* @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.
|
|
57
57
|
*
|
|
@@ -61,6 +61,6 @@ declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchPro
|
|
|
61
61
|
* const result = findIndex(items, 'name');
|
|
62
62
|
* console.log(result); // 0
|
|
63
63
|
*/
|
|
64
|
-
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
64
|
+
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey, fromIndex?: number): number;
|
|
65
65
|
|
|
66
66
|
export { findIndex };
|
|
@@ -47,11 +47,11 @@ declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatch: P
|
|
|
47
47
|
*/
|
|
48
48
|
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown], fromIndex?: number): number;
|
|
49
49
|
/**
|
|
50
|
-
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a
|
|
50
|
+
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
51
51
|
*
|
|
52
52
|
* @template T
|
|
53
53
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
55
55
|
* @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.
|
|
56
56
|
* @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.
|
|
57
57
|
*
|
|
@@ -61,6 +61,6 @@ declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchPro
|
|
|
61
61
|
* const result = findIndex(items, 'name');
|
|
62
62
|
* console.log(result); // 0
|
|
63
63
|
*/
|
|
64
|
-
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
64
|
+
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey, fromIndex?: number): number;
|
|
65
65
|
|
|
66
66
|
export { findIndex };
|
|
@@ -47,11 +47,11 @@ declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatc
|
|
|
47
47
|
*/
|
|
48
48
|
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown], fromIndex?: number): number;
|
|
49
49
|
/**
|
|
50
|
-
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a
|
|
50
|
+
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
51
51
|
*
|
|
52
52
|
* @template T
|
|
53
53
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
55
55
|
* @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.
|
|
56
56
|
* @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.
|
|
57
57
|
*
|
|
@@ -61,6 +61,6 @@ declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatc
|
|
|
61
61
|
* const result = findLastIndex(items, 'name');
|
|
62
62
|
* console.log(result); // 1
|
|
63
63
|
*/
|
|
64
|
-
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
64
|
+
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey, fromIndex?: number): number;
|
|
65
65
|
|
|
66
66
|
export { findLastIndex };
|
|
@@ -47,11 +47,11 @@ declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatc
|
|
|
47
47
|
*/
|
|
48
48
|
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatchProperty: [keyof T, unknown], fromIndex?: number): number;
|
|
49
49
|
/**
|
|
50
|
-
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a
|
|
50
|
+
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|
51
51
|
*
|
|
52
52
|
* @template T
|
|
53
53
|
* @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {PropertyKey} propertyToCheck - The property name to check.
|
|
55
55
|
* @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.
|
|
56
56
|
* @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.
|
|
57
57
|
*
|
|
@@ -61,6 +61,6 @@ declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatc
|
|
|
61
61
|
* const result = findLastIndex(items, 'name');
|
|
62
62
|
* console.log(result); // 1
|
|
63
63
|
*/
|
|
64
|
-
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
64
|
+
declare function findLastIndex<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey, fromIndex?: number): number;
|
|
65
65
|
|
|
66
66
|
export { findLastIndex };
|
|
@@ -41,14 +41,14 @@ declare function some<T>(arr: ArrayLike<T> | null | undefined, predicate: [keyof
|
|
|
41
41
|
*
|
|
42
42
|
* @template T
|
|
43
43
|
* @param {ArrayLike<T> | null | undefined} arr The array to iterate over.
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {PropertyKey} propertyToCheck The property name to check.
|
|
45
45
|
* @returns {boolean} Returns `true` if any element has a truthy value for the property, else `false`.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* some([{ a: 1 }, { a: 2 }, { a: 3 }], 'a');
|
|
49
49
|
* // => true
|
|
50
50
|
*/
|
|
51
|
-
declare function some<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
51
|
+
declare function some<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Checks if there is an element in an array that matches the given partial object.
|
|
54
54
|
*
|
|
@@ -115,11 +115,11 @@ declare function some<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
115
115
|
*/
|
|
116
116
|
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): boolean;
|
|
117
117
|
/**
|
|
118
|
-
* Checks if there is an element in an object that has a specific property, where the property name is provided as a
|
|
118
|
+
* Checks if there is an element in an object that has a specific property, where the property name is provided as a PropertyKey.
|
|
119
119
|
*
|
|
120
120
|
* @template T
|
|
121
121
|
* @param {T | null | undefined} object The object to iterate over.
|
|
122
|
-
* @param {
|
|
122
|
+
* @param {PropertyKey} propertyToCheck The property name to check.
|
|
123
123
|
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
|
|
124
124
|
*
|
|
125
125
|
* @example
|
|
@@ -127,6 +127,6 @@ declare function some<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
127
127
|
* const result = some(obj, 'name');
|
|
128
128
|
* // => true
|
|
129
129
|
*/
|
|
130
|
-
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
130
|
+
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
131
131
|
|
|
132
132
|
export { some };
|
|
@@ -41,14 +41,14 @@ declare function some<T>(arr: ArrayLike<T> | null | undefined, predicate: [keyof
|
|
|
41
41
|
*
|
|
42
42
|
* @template T
|
|
43
43
|
* @param {ArrayLike<T> | null | undefined} arr The array to iterate over.
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {PropertyKey} propertyToCheck The property name to check.
|
|
45
45
|
* @returns {boolean} Returns `true` if any element has a truthy value for the property, else `false`.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* some([{ a: 1 }, { a: 2 }, { a: 3 }], 'a');
|
|
49
49
|
* // => true
|
|
50
50
|
*/
|
|
51
|
-
declare function some<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck:
|
|
51
|
+
declare function some<T>(arr: ArrayLike<T> | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Checks if there is an element in an array that matches the given partial object.
|
|
54
54
|
*
|
|
@@ -115,11 +115,11 @@ declare function some<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
115
115
|
*/
|
|
116
116
|
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, doesMatchProperty: [keyof T[keyof T], unknown]): boolean;
|
|
117
117
|
/**
|
|
118
|
-
* Checks if there is an element in an object that has a specific property, where the property name is provided as a
|
|
118
|
+
* Checks if there is an element in an object that has a specific property, where the property name is provided as a PropertyKey.
|
|
119
119
|
*
|
|
120
120
|
* @template T
|
|
121
121
|
* @param {T | null | undefined} object The object to iterate over.
|
|
122
|
-
* @param {
|
|
122
|
+
* @param {PropertyKey} propertyToCheck The property name to check.
|
|
123
123
|
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
|
|
124
124
|
*
|
|
125
125
|
* @example
|
|
@@ -127,6 +127,6 @@ declare function some<T extends Record<string, unknown>>(object: T | null | unde
|
|
|
127
127
|
* const result = some(obj, 'name');
|
|
128
128
|
* // => true
|
|
129
129
|
*/
|
|
130
|
-
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck:
|
|
130
|
+
declare function some<T extends Record<string, unknown>>(object: T | null | undefined, propertyToCheck: PropertyKey): boolean;
|
|
131
131
|
|
|
132
132
|
export { some };
|
package/dist/compat/index.js
CHANGED
|
@@ -552,6 +552,8 @@ function dropRightWhileImpl(arr, predicate) {
|
|
|
552
552
|
return zipWith.dropRightWhile(arr, matches(predicate));
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
+
case 'symbol':
|
|
556
|
+
case 'number':
|
|
555
557
|
case 'string': {
|
|
556
558
|
return zipWith.dropRightWhile(arr, property(predicate));
|
|
557
559
|
}
|
|
@@ -579,6 +581,8 @@ function dropWhileImpl(arr, predicate) {
|
|
|
579
581
|
return zipWith.dropWhile(arr, matches(predicate));
|
|
580
582
|
}
|
|
581
583
|
}
|
|
584
|
+
case 'number':
|
|
585
|
+
case 'symbol':
|
|
582
586
|
case 'string': {
|
|
583
587
|
return zipWith.dropWhile(arr, property(predicate));
|
|
584
588
|
}
|
|
@@ -632,6 +636,8 @@ function every(source, doesMatch, guard) {
|
|
|
632
636
|
return values.every(matches(doesMatch));
|
|
633
637
|
}
|
|
634
638
|
}
|
|
639
|
+
case 'symbol':
|
|
640
|
+
case 'number':
|
|
635
641
|
case 'string': {
|
|
636
642
|
return values.every(property(doesMatch));
|
|
637
643
|
}
|
|
@@ -693,6 +699,8 @@ function filter(source, predicate) {
|
|
|
693
699
|
? collection.filter(matchesProperty(predicate[0], predicate[1]))
|
|
694
700
|
: collection.filter(matches(predicate));
|
|
695
701
|
}
|
|
702
|
+
case 'symbol':
|
|
703
|
+
case 'number':
|
|
696
704
|
case 'string': {
|
|
697
705
|
return collection.filter(property(predicate));
|
|
698
706
|
}
|
|
@@ -729,6 +737,8 @@ function find(source, doesMatch) {
|
|
|
729
737
|
return values.find(matches(doesMatch));
|
|
730
738
|
}
|
|
731
739
|
}
|
|
740
|
+
case 'symbol':
|
|
741
|
+
case 'number':
|
|
732
742
|
case 'string': {
|
|
733
743
|
return values.find(property(doesMatch));
|
|
734
744
|
}
|
|
@@ -760,6 +770,8 @@ function findIndex(arr, doesMatch, fromIndex = 0) {
|
|
|
760
770
|
}
|
|
761
771
|
break;
|
|
762
772
|
}
|
|
773
|
+
case 'number':
|
|
774
|
+
case 'symbol':
|
|
763
775
|
case 'string': {
|
|
764
776
|
index = subArray.findIndex(property(doesMatch));
|
|
765
777
|
}
|
|
@@ -792,6 +804,8 @@ function findLastIndex(arr, doesMatch, fromIndex = arr ? arr.length - 1 : 0) {
|
|
|
792
804
|
return subArray.findLastIndex(matches(doesMatch));
|
|
793
805
|
}
|
|
794
806
|
}
|
|
807
|
+
case 'number':
|
|
808
|
+
case 'symbol':
|
|
795
809
|
case 'string': {
|
|
796
810
|
return subArray.findLastIndex(property(doesMatch));
|
|
797
811
|
}
|
|
@@ -1176,6 +1190,8 @@ function some(source, predicate, guard) {
|
|
|
1176
1190
|
return values.some(matches(predicate));
|
|
1177
1191
|
}
|
|
1178
1192
|
}
|
|
1193
|
+
case 'number':
|
|
1194
|
+
case 'symbol':
|
|
1179
1195
|
case 'string': {
|
|
1180
1196
|
return values.some(property(predicate));
|
|
1181
1197
|
}
|