es-toolkit 1.35.0-dev.1171 → 1.35.0-dev.1173
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/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +21 -0
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/util/overSome.d.mts +69 -0
- package/dist/compat/util/overSome.d.ts +69 -0
- package/dist/compat/util/overSome.mjs +23 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -284,6 +284,7 @@ export { method } from './util/method.mjs';
|
|
|
284
284
|
export { methodOf } from './util/methodOf.mjs';
|
|
285
285
|
export { now } from './util/now.mjs';
|
|
286
286
|
export { over } from './util/over.mjs';
|
|
287
|
+
export { overSome } from './util/overSome.mjs';
|
|
287
288
|
export { stubArray } from './util/stubArray.mjs';
|
|
288
289
|
export { stubFalse } from './util/stubFalse.mjs';
|
|
289
290
|
export { stubObject } from './util/stubObject.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -284,6 +284,7 @@ export { method } from './util/method.js';
|
|
|
284
284
|
export { methodOf } from './util/methodOf.js';
|
|
285
285
|
export { now } from './util/now.js';
|
|
286
286
|
export { over } from './util/over.js';
|
|
287
|
+
export { overSome } from './util/overSome.js';
|
|
287
288
|
export { stubArray } from './util/stubArray.js';
|
|
288
289
|
export { stubFalse } from './util/stubFalse.js';
|
|
289
290
|
export { stubObject } from './util/stubObject.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -3498,6 +3498,26 @@ function over(...iteratees) {
|
|
|
3498
3498
|
};
|
|
3499
3499
|
}
|
|
3500
3500
|
|
|
3501
|
+
function overSome(...predicates) {
|
|
3502
|
+
return function (...values) {
|
|
3503
|
+
for (let i = 0; i < predicates.length; ++i) {
|
|
3504
|
+
const predicate = predicates[i];
|
|
3505
|
+
if (!Array.isArray(predicate)) {
|
|
3506
|
+
if (iteratee(predicate).apply(this, values)) {
|
|
3507
|
+
return true;
|
|
3508
|
+
}
|
|
3509
|
+
continue;
|
|
3510
|
+
}
|
|
3511
|
+
for (let j = 0; j < predicate.length; ++j) {
|
|
3512
|
+
if (iteratee(predicate[j]).apply(this, values)) {
|
|
3513
|
+
return true;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
return false;
|
|
3518
|
+
};
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3501
3521
|
function stubArray() {
|
|
3502
3522
|
return [];
|
|
3503
3523
|
}
|
|
@@ -3788,6 +3808,7 @@ exports.nthArg = nthArg;
|
|
|
3788
3808
|
exports.omit = omit;
|
|
3789
3809
|
exports.orderBy = orderBy;
|
|
3790
3810
|
exports.over = over;
|
|
3811
|
+
exports.overSome = overSome;
|
|
3791
3812
|
exports.pad = pad;
|
|
3792
3813
|
exports.padEnd = padEnd;
|
|
3793
3814
|
exports.padStart = padStart;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -284,6 +284,7 @@ export { method } from './util/method.mjs';
|
|
|
284
284
|
export { methodOf } from './util/methodOf.mjs';
|
|
285
285
|
export { now } from './util/now.mjs';
|
|
286
286
|
export { over } from './util/over.mjs';
|
|
287
|
+
export { overSome } from './util/overSome.mjs';
|
|
287
288
|
export { stubArray } from './util/stubArray.mjs';
|
|
288
289
|
export { stubFalse } from './util/stubFalse.mjs';
|
|
289
290
|
export { stubObject } from './util/stubObject.mjs';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a predicate function that checks if a value satisfies at least one of the given predicates.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the value to be checked.
|
|
5
|
+
* @template U - The first possible type that the value could match.
|
|
6
|
+
* @template V - The second possible type that the value could match.
|
|
7
|
+
*
|
|
8
|
+
* @param {(value: T) => value is U} predicate1 - A function that checks if the value matches type `U`.
|
|
9
|
+
* @param {(value: T) => value is V} predicate2 - A function that checks if the value matches type `V`.
|
|
10
|
+
*
|
|
11
|
+
* @returns {(value: T) => value is U | V} A function that takes a value and returns `true` if any predicates return truthy.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const func = overSome(
|
|
15
|
+
* (value) => typeof value === 'string',
|
|
16
|
+
* (value) => typeof value === 'number'
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* func("hello"); // true
|
|
20
|
+
* func(42); // true
|
|
21
|
+
* func([]); // false
|
|
22
|
+
*/
|
|
23
|
+
declare function overSome<T, U extends T, V extends T>(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U | V;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a function that checks if any of the given predicates return truthy for the provided values.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The type of the values to be checked.
|
|
28
|
+
*
|
|
29
|
+
* @param {...Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>} predicates -
|
|
30
|
+
* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of
|
|
31
|
+
* type `T` and returns a boolean indicating whether the condition is satisfied for those values.
|
|
32
|
+
*
|
|
33
|
+
* @returns {(...values: T[]) => boolean} A function that takes a list of values and returns `true` if any of the
|
|
34
|
+
* predicates return truthy for the provided values, and `false` otherwise.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const func = overSome(
|
|
38
|
+
* (value) => typeof value === 'string',
|
|
39
|
+
* (value) => typeof value === 'number',
|
|
40
|
+
* (value) => typeof value === 'symbol'
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* func("hello"); // true
|
|
44
|
+
* func(42); // true
|
|
45
|
+
* func(Symbol()); // true
|
|
46
|
+
* func([]); // false
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const func = overSome([
|
|
50
|
+
* (value) => value.a > 0,
|
|
51
|
+
* (value) => value.b > 0
|
|
52
|
+
* ]);
|
|
53
|
+
*
|
|
54
|
+
* func({ a: 0, b: 2 }); // true
|
|
55
|
+
* func({ a: 0, b: 0 }); // false
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const func = overSome(
|
|
59
|
+
* (a, b) => typeof a === 'string' && typeof b === 'string',
|
|
60
|
+
* (a, b) => a > 0 && b > 0
|
|
61
|
+
* );
|
|
62
|
+
*
|
|
63
|
+
* func("hello", "world"); // true
|
|
64
|
+
* func(1, 10); // true
|
|
65
|
+
* func(0, 2); // false
|
|
66
|
+
*/
|
|
67
|
+
declare function overSome<T>(...predicates: Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>): (...values: T[]) => boolean;
|
|
68
|
+
|
|
69
|
+
export { overSome };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a predicate function that checks if a value satisfies at least one of the given predicates.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the value to be checked.
|
|
5
|
+
* @template U - The first possible type that the value could match.
|
|
6
|
+
* @template V - The second possible type that the value could match.
|
|
7
|
+
*
|
|
8
|
+
* @param {(value: T) => value is U} predicate1 - A function that checks if the value matches type `U`.
|
|
9
|
+
* @param {(value: T) => value is V} predicate2 - A function that checks if the value matches type `V`.
|
|
10
|
+
*
|
|
11
|
+
* @returns {(value: T) => value is U | V} A function that takes a value and returns `true` if any predicates return truthy.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const func = overSome(
|
|
15
|
+
* (value) => typeof value === 'string',
|
|
16
|
+
* (value) => typeof value === 'number'
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* func("hello"); // true
|
|
20
|
+
* func(42); // true
|
|
21
|
+
* func([]); // false
|
|
22
|
+
*/
|
|
23
|
+
declare function overSome<T, U extends T, V extends T>(predicate1: (value: T) => value is U, predicate2: (value: T) => value is V): (value: T) => value is U | V;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a function that checks if any of the given predicates return truthy for the provided values.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The type of the values to be checked.
|
|
28
|
+
*
|
|
29
|
+
* @param {...Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>} predicates -
|
|
30
|
+
* A list of predicates or arrays of predicates. Each predicate is a function that takes one or more values of
|
|
31
|
+
* type `T` and returns a boolean indicating whether the condition is satisfied for those values.
|
|
32
|
+
*
|
|
33
|
+
* @returns {(...values: T[]) => boolean} A function that takes a list of values and returns `true` if any of the
|
|
34
|
+
* predicates return truthy for the provided values, and `false` otherwise.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const func = overSome(
|
|
38
|
+
* (value) => typeof value === 'string',
|
|
39
|
+
* (value) => typeof value === 'number',
|
|
40
|
+
* (value) => typeof value === 'symbol'
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* func("hello"); // true
|
|
44
|
+
* func(42); // true
|
|
45
|
+
* func(Symbol()); // true
|
|
46
|
+
* func([]); // false
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const func = overSome([
|
|
50
|
+
* (value) => value.a > 0,
|
|
51
|
+
* (value) => value.b > 0
|
|
52
|
+
* ]);
|
|
53
|
+
*
|
|
54
|
+
* func({ a: 0, b: 2 }); // true
|
|
55
|
+
* func({ a: 0, b: 0 }); // false
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const func = overSome(
|
|
59
|
+
* (a, b) => typeof a === 'string' && typeof b === 'string',
|
|
60
|
+
* (a, b) => a > 0 && b > 0
|
|
61
|
+
* );
|
|
62
|
+
*
|
|
63
|
+
* func("hello", "world"); // true
|
|
64
|
+
* func(1, 10); // true
|
|
65
|
+
* func(0, 2); // false
|
|
66
|
+
*/
|
|
67
|
+
declare function overSome<T>(...predicates: Array<((...values: T[]) => boolean) | ReadonlyArray<(...values: T[]) => boolean>>): (...values: T[]) => boolean;
|
|
68
|
+
|
|
69
|
+
export { overSome };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { iteratee } from './iteratee.mjs';
|
|
2
|
+
|
|
3
|
+
function overSome(...predicates) {
|
|
4
|
+
return function (...values) {
|
|
5
|
+
for (let i = 0; i < predicates.length; ++i) {
|
|
6
|
+
const predicate = predicates[i];
|
|
7
|
+
if (!Array.isArray(predicate)) {
|
|
8
|
+
if (iteratee(predicate).apply(this, values)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
for (let j = 0; j < predicate.length; ++j) {
|
|
14
|
+
if (iteratee(predicate[j]).apply(this, values)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { overSome };
|
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.35.0-dev.
|
|
4
|
+
"version": "1.35.0-dev.1173+bdc56b74",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|