es-toolkit 1.21.0-dev.678 → 1.21.0-dev.680
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/_chunk/{zipWith-Cz3jdk.js → zipWith-EOU_KZ.js} +0 -39
- package/dist/array/index.d.mts +0 -1
- package/dist/array/index.d.ts +0 -1
- package/dist/array/index.js +1 -2
- package/dist/array/index.mjs +0 -1
- 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/function/flip.d.mts +18 -0
- package/dist/compat/function/flip.d.ts +18 -0
- package/dist/compat/function/flip.mjs +7 -0
- package/dist/compat/index.d.mts +2 -1
- package/dist/compat/index.d.ts +2 -1
- package/dist/compat/index.js +56 -6
- package/dist/compat/index.mjs +2 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/dist/index.mjs +0 -1
- package/package.json +1 -1
- package/dist/array/every.d.mts +0 -27
- package/dist/array/every.d.ts +0 -27
- package/dist/array/every.mjs +0 -39
package/dist/array/every.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if all elements in a collection pass the predicate.
|
|
3
|
-
*
|
|
4
|
-
* Returns `true` if all elements in an array, object, or string satisfy the predicate,
|
|
5
|
-
* or if the collection is `null` or `undefined`.
|
|
6
|
-
*
|
|
7
|
-
* Note: Empty arrays `[]`, empty strings `''`, and empty objects `{}` return `true` by default.
|
|
8
|
-
*
|
|
9
|
-
* @template T The type of elements in the collection.
|
|
10
|
-
* @param {T[] | { [key: string]: T } | string | null | undefined} collection - The collection to check.
|
|
11
|
-
* @param {(value: T, indexOrKey: number | string) => boolean} predicate - The function to test each element.
|
|
12
|
-
* @returns {boolean} `true` if all elements pass the predicate, `false` otherwise.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* every([1, 2, 3], (value) => value > 0); // true
|
|
16
|
-
* @example
|
|
17
|
-
* every('abc', (char) => /[a-z]/.test(char)); // true
|
|
18
|
-
* @example
|
|
19
|
-
* every({ a: 1, b: 2 }, (value) => value > 0); // true
|
|
20
|
-
*/
|
|
21
|
-
declare function every<T>(collection: T[] | null | undefined, predicate: (value: T, index: number) => boolean): boolean;
|
|
22
|
-
declare function every<T>(collection: {
|
|
23
|
-
[key: string]: T;
|
|
24
|
-
} | null | undefined, predicate: (value: T, key: string) => boolean): boolean;
|
|
25
|
-
declare function every(collection: string | null | undefined, predicate: (value: string, index: number) => boolean): boolean;
|
|
26
|
-
|
|
27
|
-
export { every };
|
package/dist/array/every.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function every(collection, predicate) {
|
|
2
|
-
if (collection == null) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
5
|
-
if (Array.isArray(collection)) {
|
|
6
|
-
if (collection.length === 0) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
for (let i = 0; i < collection.length; i++) {
|
|
10
|
-
if (!predicate(collection[i], i)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (typeof collection === 'string') {
|
|
17
|
-
if (collection.length === 0) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
for (let i = 0; i < collection.length; i++) {
|
|
21
|
-
if (!predicate(collection[i], i)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
const keys = Object.keys(collection);
|
|
28
|
-
if (keys.length === 0) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
for (const key of keys) {
|
|
32
|
-
if (!predicate(collection[key], key)) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { every };
|