es-toolkit 1.21.0-dev.677 → 1.21.0-dev.679
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/every.d.mts +139 -0
- package/dist/compat/array/every.d.ts +139 -0
- package/dist/compat/array/every.mjs +49 -0
- package/dist/compat/array/find.d.mts +1 -1
- package/dist/compat/array/find.d.ts +1 -1
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +48 -4
- package/dist/compat/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if all elements in an array are truthy.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T[]} arr - The array to check through.
|
|
6
|
+
* @returns {boolean} - `true` if all elements are truthy, or `false` if at least one element is falsy.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const items = [1, 2, 3, 4];
|
|
10
|
+
* const result = every(items);
|
|
11
|
+
* console.log(result); // true
|
|
12
|
+
*
|
|
13
|
+
* const itemsWithFalsy = [1, 0, 3, 4];
|
|
14
|
+
* const resultWithFalsy = every(itemsWithFalsy);
|
|
15
|
+
* console.log(resultWithFalsy); // false
|
|
16
|
+
*/
|
|
17
|
+
declare function every<T>(arr: readonly T[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if every item in an array matches the given predicate function.
|
|
20
|
+
*
|
|
21
|
+
* @template T
|
|
22
|
+
* @param {T[]} arr - The array to check through.
|
|
23
|
+
* @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.
|
|
24
|
+
* @returns {boolean} - `true` if every item matches the predicate, or `false` if at least one item does not match.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Using a predicate function
|
|
28
|
+
* const items = [1, 2, 3, 4, 5];
|
|
29
|
+
* const result = every(items, (item) => item > 0);
|
|
30
|
+
* console.log(result); // true
|
|
31
|
+
*/
|
|
32
|
+
declare function every<T>(arr: readonly T[], doesMatch: (item: T, index: number, arr: readonly T[]) => unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if every item in an array matches the given partial object.
|
|
35
|
+
*
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {T[]} arr - The array to check through.
|
|
38
|
+
* @param {Partial<T>} doesMatch - A partial object that specifies the properties to match.
|
|
39
|
+
* @returns {boolean} - `true` if every item matches the partial object, or `false` if at least one item does not match.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Using a partial object
|
|
43
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
44
|
+
* const result = every(items, { name: 'Bob' });
|
|
45
|
+
* console.log(result); // false
|
|
46
|
+
*/
|
|
47
|
+
declare function every<T>(arr: readonly T[], doesMatch: Partial<T>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if every item in an array matches a property with a specific value.
|
|
50
|
+
*
|
|
51
|
+
* @template T
|
|
52
|
+
* @param {readonly T[]} arr - The array to check through.
|
|
53
|
+
* @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.
|
|
54
|
+
* @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Using a property-value pair
|
|
58
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
59
|
+
* const result = every(items, ['name', 'Alice']);
|
|
60
|
+
* console.log(result); // false
|
|
61
|
+
*/
|
|
62
|
+
declare function every<T>(arr: readonly T[], doesMatchProperty: [keyof T, unknown]): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if every item in an array has a specific property, where the property name is provided as a string.
|
|
65
|
+
*
|
|
66
|
+
* @template T
|
|
67
|
+
* @param {readonly T[]} arr - The array to check through.
|
|
68
|
+
* @param {string} propertyToCheck - The property name to check.
|
|
69
|
+
* @returns {boolean} - `true` if every item has the specified property, or `false` if at least one item does not match.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Using a property name
|
|
73
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
74
|
+
* const result = every(items, 'name');
|
|
75
|
+
* console.log(result); // true
|
|
76
|
+
*/
|
|
77
|
+
declare function every<T>(arr: readonly T[], propertyToCheck: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if every item in an object matches the given predicate function.
|
|
80
|
+
*
|
|
81
|
+
* @template T
|
|
82
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
83
|
+
* @param {(item: T[keyof T], index: keyof T, arr: T) => unknown} doesMatch - A function that takes an item, its key, and the object, and returns a truthy value if the item matches the criteria.
|
|
84
|
+
* @returns {boolean} - `true` if every property value matches the predicate, or `false` if at least one does not match.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Using a predicate function
|
|
88
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
89
|
+
* const result = every(obj, (item) => item > 0);
|
|
90
|
+
* console.log(result); // true
|
|
91
|
+
*/
|
|
92
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index: keyof T, object: T) => unknown): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if every item in an object matches the given partial value.
|
|
95
|
+
*
|
|
96
|
+
* @template T
|
|
97
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
98
|
+
* @param {Partial<T[keyof T]>} doesMatch - A partial value to match against the values of the object.
|
|
99
|
+
* @returns {boolean} - `true` if every property value matches the partial value, or `false` if at least one does not match.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Using a partial value
|
|
103
|
+
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
|
|
104
|
+
* const result = every(obj, { name: 'Bob' });
|
|
105
|
+
* console.log(result); // false
|
|
106
|
+
*/
|
|
107
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatch: Partial<T[keyof T]>): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Checks if every item in an object matches a property with a specific value.
|
|
110
|
+
*
|
|
111
|
+
* @template T
|
|
112
|
+
* @param {readonly T[]} object - The object to check through.
|
|
113
|
+
* @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.
|
|
114
|
+
* @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // Using a property-value pair
|
|
118
|
+
* const items = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };
|
|
119
|
+
* const result = every(items, ['name', 'Alice']);
|
|
120
|
+
* console.log(result); // false
|
|
121
|
+
*/
|
|
122
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatchProperty: [keyof T, unknown]): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if every item in an object has a specific property, where the property name is provided as a string.
|
|
125
|
+
*
|
|
126
|
+
* @template T
|
|
127
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
128
|
+
* @param {string} propertyToCheck - The property name to check.
|
|
129
|
+
* @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Using a property name
|
|
133
|
+
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
|
|
134
|
+
* const result = every(obj, 'name');
|
|
135
|
+
* console.log(result); // true
|
|
136
|
+
*/
|
|
137
|
+
declare function every<T extends Record<string, unknown>>(object: T, propertyToCheck: string): boolean;
|
|
138
|
+
|
|
139
|
+
export { every };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if all elements in an array are truthy.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T[]} arr - The array to check through.
|
|
6
|
+
* @returns {boolean} - `true` if all elements are truthy, or `false` if at least one element is falsy.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const items = [1, 2, 3, 4];
|
|
10
|
+
* const result = every(items);
|
|
11
|
+
* console.log(result); // true
|
|
12
|
+
*
|
|
13
|
+
* const itemsWithFalsy = [1, 0, 3, 4];
|
|
14
|
+
* const resultWithFalsy = every(itemsWithFalsy);
|
|
15
|
+
* console.log(resultWithFalsy); // false
|
|
16
|
+
*/
|
|
17
|
+
declare function every<T>(arr: readonly T[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if every item in an array matches the given predicate function.
|
|
20
|
+
*
|
|
21
|
+
* @template T
|
|
22
|
+
* @param {T[]} arr - The array to check through.
|
|
23
|
+
* @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.
|
|
24
|
+
* @returns {boolean} - `true` if every item matches the predicate, or `false` if at least one item does not match.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Using a predicate function
|
|
28
|
+
* const items = [1, 2, 3, 4, 5];
|
|
29
|
+
* const result = every(items, (item) => item > 0);
|
|
30
|
+
* console.log(result); // true
|
|
31
|
+
*/
|
|
32
|
+
declare function every<T>(arr: readonly T[], doesMatch: (item: T, index: number, arr: readonly T[]) => unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if every item in an array matches the given partial object.
|
|
35
|
+
*
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {T[]} arr - The array to check through.
|
|
38
|
+
* @param {Partial<T>} doesMatch - A partial object that specifies the properties to match.
|
|
39
|
+
* @returns {boolean} - `true` if every item matches the partial object, or `false` if at least one item does not match.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Using a partial object
|
|
43
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
44
|
+
* const result = every(items, { name: 'Bob' });
|
|
45
|
+
* console.log(result); // false
|
|
46
|
+
*/
|
|
47
|
+
declare function every<T>(arr: readonly T[], doesMatch: Partial<T>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if every item in an array matches a property with a specific value.
|
|
50
|
+
*
|
|
51
|
+
* @template T
|
|
52
|
+
* @param {readonly T[]} arr - The array to check through.
|
|
53
|
+
* @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.
|
|
54
|
+
* @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Using a property-value pair
|
|
58
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
59
|
+
* const result = every(items, ['name', 'Alice']);
|
|
60
|
+
* console.log(result); // false
|
|
61
|
+
*/
|
|
62
|
+
declare function every<T>(arr: readonly T[], doesMatchProperty: [keyof T, unknown]): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if every item in an array has a specific property, where the property name is provided as a string.
|
|
65
|
+
*
|
|
66
|
+
* @template T
|
|
67
|
+
* @param {readonly T[]} arr - The array to check through.
|
|
68
|
+
* @param {string} propertyToCheck - The property name to check.
|
|
69
|
+
* @returns {boolean} - `true` if every item has the specified property, or `false` if at least one item does not match.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Using a property name
|
|
73
|
+
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
74
|
+
* const result = every(items, 'name');
|
|
75
|
+
* console.log(result); // true
|
|
76
|
+
*/
|
|
77
|
+
declare function every<T>(arr: readonly T[], propertyToCheck: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if every item in an object matches the given predicate function.
|
|
80
|
+
*
|
|
81
|
+
* @template T
|
|
82
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
83
|
+
* @param {(item: T[keyof T], index: keyof T, arr: T) => unknown} doesMatch - A function that takes an item, its key, and the object, and returns a truthy value if the item matches the criteria.
|
|
84
|
+
* @returns {boolean} - `true` if every property value matches the predicate, or `false` if at least one does not match.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Using a predicate function
|
|
88
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
89
|
+
* const result = every(obj, (item) => item > 0);
|
|
90
|
+
* console.log(result); // true
|
|
91
|
+
*/
|
|
92
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index: keyof T, object: T) => unknown): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if every item in an object matches the given partial value.
|
|
95
|
+
*
|
|
96
|
+
* @template T
|
|
97
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
98
|
+
* @param {Partial<T[keyof T]>} doesMatch - A partial value to match against the values of the object.
|
|
99
|
+
* @returns {boolean} - `true` if every property value matches the partial value, or `false` if at least one does not match.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Using a partial value
|
|
103
|
+
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
|
|
104
|
+
* const result = every(obj, { name: 'Bob' });
|
|
105
|
+
* console.log(result); // false
|
|
106
|
+
*/
|
|
107
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatch: Partial<T[keyof T]>): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Checks if every item in an object matches a property with a specific value.
|
|
110
|
+
*
|
|
111
|
+
* @template T
|
|
112
|
+
* @param {readonly T[]} object - The object to check through.
|
|
113
|
+
* @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.
|
|
114
|
+
* @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // Using a property-value pair
|
|
118
|
+
* const items = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };
|
|
119
|
+
* const result = every(items, ['name', 'Alice']);
|
|
120
|
+
* console.log(result); // false
|
|
121
|
+
*/
|
|
122
|
+
declare function every<T extends Record<string, unknown>>(object: T, doesMatchProperty: [keyof T, unknown]): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if every item in an object has a specific property, where the property name is provided as a string.
|
|
125
|
+
*
|
|
126
|
+
* @template T
|
|
127
|
+
* @param {T extends Record<string, unknown> ? T : never} object - The object to check through.
|
|
128
|
+
* @param {string} propertyToCheck - The property name to check.
|
|
129
|
+
* @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* // Using a property name
|
|
133
|
+
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
|
|
134
|
+
* const result = every(obj, 'name');
|
|
135
|
+
* console.log(result); // true
|
|
136
|
+
*/
|
|
137
|
+
declare function every<T extends Record<string, unknown>>(object: T, propertyToCheck: string): boolean;
|
|
138
|
+
|
|
139
|
+
export { every };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { identity } from '../_internal/identity.mjs';
|
|
2
|
+
import { property } from '../object/property.mjs';
|
|
3
|
+
import { matches } from '../predicate/matches.mjs';
|
|
4
|
+
import { matchesProperty } from '../predicate/matchesProperty.mjs';
|
|
5
|
+
|
|
6
|
+
function every(source, doesMatch) {
|
|
7
|
+
if (!source) {
|
|
8
|
+
source = [];
|
|
9
|
+
}
|
|
10
|
+
let values = source;
|
|
11
|
+
if (!Array.isArray(source)) {
|
|
12
|
+
values = Object.values(source);
|
|
13
|
+
}
|
|
14
|
+
if (!doesMatch) {
|
|
15
|
+
doesMatch = identity;
|
|
16
|
+
}
|
|
17
|
+
switch (typeof doesMatch) {
|
|
18
|
+
case 'function': {
|
|
19
|
+
if (!Array.isArray(source)) {
|
|
20
|
+
const entries = Object.entries(source);
|
|
21
|
+
for (let i = 0; i < entries.length; i++) {
|
|
22
|
+
const entry = entries[i];
|
|
23
|
+
const key = entry[0];
|
|
24
|
+
const value = entry[1];
|
|
25
|
+
if (!doesMatch(value, key, source)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return values.every(doesMatch);
|
|
32
|
+
}
|
|
33
|
+
case 'object': {
|
|
34
|
+
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
35
|
+
const key = doesMatch[0];
|
|
36
|
+
const value = doesMatch[1];
|
|
37
|
+
return values.every(matchesProperty(key, value));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return values.every(matches(doesMatch));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
case 'string': {
|
|
44
|
+
return values.every(property(doesMatch));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { every };
|
|
@@ -72,7 +72,7 @@ declare function find<T>(arr: readonly T[], propertyToCheck: string): T | undefi
|
|
|
72
72
|
* const result = find(obj, (item) => item > 2);
|
|
73
73
|
* console.log(result); // 3
|
|
74
74
|
*/
|
|
75
|
-
declare function find<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index:
|
|
75
|
+
declare function find<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index: keyof T, object: T) => unknown): T | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* Finds the first item in an object that matches the given partial value.
|
|
78
78
|
*
|
|
@@ -72,7 +72,7 @@ declare function find<T>(arr: readonly T[], propertyToCheck: string): T | undefi
|
|
|
72
72
|
* const result = find(obj, (item) => item > 2);
|
|
73
73
|
* console.log(result); // 3
|
|
74
74
|
*/
|
|
75
|
-
declare function find<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index:
|
|
75
|
+
declare function find<T extends Record<string, unknown>>(object: T, doesMatch: (item: T[keyof T], index: keyof T, object: T) => unknown): T | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* Finds the first item in an object that matches the given partial value.
|
|
78
78
|
*
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -97,6 +97,7 @@ export { concat } from './array/concat.mjs';
|
|
|
97
97
|
export { difference } from './array/difference.mjs';
|
|
98
98
|
export { drop } from './array/drop.mjs';
|
|
99
99
|
export { dropWhile } from './array/dropWhile.mjs';
|
|
100
|
+
export { every } from './array/every.mjs';
|
|
100
101
|
export { fill } from './array/fill.mjs';
|
|
101
102
|
export { find } from './array/find.mjs';
|
|
102
103
|
export { findIndex } from './array/findIndex.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export { concat } from './array/concat.js';
|
|
|
97
97
|
export { difference } from './array/difference.js';
|
|
98
98
|
export { drop } from './array/drop.js';
|
|
99
99
|
export { dropWhile } from './array/dropWhile.js';
|
|
100
|
+
export { every } from './array/every.js';
|
|
100
101
|
export { fill } from './array/fill.js';
|
|
101
102
|
export { find } from './array/find.js';
|
|
102
103
|
export { findIndex } from './array/findIndex.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -389,6 +389,53 @@ function dropWhile(arr, predicate) {
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
function identity(x) {
|
|
393
|
+
return x;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function every(source, doesMatch) {
|
|
397
|
+
if (!source) {
|
|
398
|
+
source = [];
|
|
399
|
+
}
|
|
400
|
+
let values = source;
|
|
401
|
+
if (!Array.isArray(source)) {
|
|
402
|
+
values = Object.values(source);
|
|
403
|
+
}
|
|
404
|
+
if (!doesMatch) {
|
|
405
|
+
doesMatch = identity;
|
|
406
|
+
}
|
|
407
|
+
switch (typeof doesMatch) {
|
|
408
|
+
case 'function': {
|
|
409
|
+
if (!Array.isArray(source)) {
|
|
410
|
+
const entries = Object.entries(source);
|
|
411
|
+
for (let i = 0; i < entries.length; i++) {
|
|
412
|
+
const entry = entries[i];
|
|
413
|
+
const key = entry[0];
|
|
414
|
+
const value = entry[1];
|
|
415
|
+
if (!doesMatch(value, key, source)) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
return values.every(doesMatch);
|
|
422
|
+
}
|
|
423
|
+
case 'object': {
|
|
424
|
+
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
425
|
+
const key = doesMatch[0];
|
|
426
|
+
const value = doesMatch[1];
|
|
427
|
+
return values.every(matchesProperty(key, value));
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
return values.every(matches(doesMatch));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
case 'string': {
|
|
434
|
+
return values.every(property(doesMatch));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
392
439
|
function fill(array, value, start = 0, end = array.length) {
|
|
393
440
|
start = Math.floor(start);
|
|
394
441
|
end = Math.floor(end);
|
|
@@ -682,10 +729,6 @@ function size(target) {
|
|
|
682
729
|
return Object.keys(target).length;
|
|
683
730
|
}
|
|
684
731
|
|
|
685
|
-
function identity(x) {
|
|
686
|
-
return x;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
732
|
function some(arr, predicate, guard) {
|
|
690
733
|
if (guard != null) {
|
|
691
734
|
predicate = undefined;
|
|
@@ -1784,6 +1827,7 @@ exports.difference = difference;
|
|
|
1784
1827
|
exports.drop = drop;
|
|
1785
1828
|
exports.dropWhile = dropWhile;
|
|
1786
1829
|
exports.endsWith = endsWith;
|
|
1830
|
+
exports.every = every;
|
|
1787
1831
|
exports.fill = fill;
|
|
1788
1832
|
exports.find = find;
|
|
1789
1833
|
exports.findIndex = findIndex;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -98,6 +98,7 @@ export { concat } from './array/concat.mjs';
|
|
|
98
98
|
export { difference } from './array/difference.mjs';
|
|
99
99
|
export { drop } from './array/drop.mjs';
|
|
100
100
|
export { dropWhile } from './array/dropWhile.mjs';
|
|
101
|
+
export { every } from './array/every.mjs';
|
|
101
102
|
export { fill } from './array/fill.mjs';
|
|
102
103
|
export { find } from './array/find.mjs';
|
|
103
104
|
export { findIndex } from './array/findIndex.mjs';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.21.0-dev.
|
|
4
|
+
"version": "1.21.0-dev.679+efe79322",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|