es-toolkit 1.35.0 → 1.36.0-dev.1217

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_chunk/{isPromise-ByAybB.js → isPromise-CxqI1v.js} +122 -36
  3. package/dist/_chunk/{reverseString-D-wK2p.js → reverseString-BixeGz.js} +84 -13
  4. package/dist/_chunk/toSnakeCaseKeys-DZO2eB.js +4901 -0
  5. package/dist/_chunk/{unary-BsNWRM.js → unary-EIEhcF.js} +46 -0
  6. package/dist/_chunk/{zip-_HttSl.js → zip-BJSrRi.js} +38 -57
  7. package/dist/array/index.js +55 -6
  8. package/dist/array/pullAt.d.mts +0 -2
  9. package/dist/array/pullAt.d.ts +0 -2
  10. package/dist/array/take.d.mts +1 -1
  11. package/dist/array/take.d.ts +1 -1
  12. package/dist/array/take.mjs +4 -1
  13. package/dist/array/takeRight.d.mts +1 -1
  14. package/dist/array/takeRight.d.ts +1 -1
  15. package/dist/array/takeRight.mjs +5 -2
  16. package/dist/browser.global.js +1 -1
  17. package/dist/browser.global.js.map +1 -1
  18. package/dist/compat/_internal/copyArray.mjs +12 -0
  19. package/dist/compat/_internal/mapToEntries.mjs +11 -0
  20. package/dist/compat/_internal/setToEntries.mjs +11 -0
  21. package/dist/compat/_internal/toKey.mjs +2 -2
  22. package/dist/compat/array/find.mjs +3 -3
  23. package/dist/compat/array/findLast.mjs +2 -2
  24. package/dist/compat/array/flatMap.d.mts +20 -0
  25. package/dist/compat/array/flatMap.d.ts +20 -0
  26. package/dist/compat/array/flatMap.mjs +13 -0
  27. package/dist/compat/array/forEachRight.d.mts +106 -0
  28. package/dist/compat/array/forEachRight.d.ts +106 -0
  29. package/dist/compat/array/forEachRight.mjs +21 -0
  30. package/dist/compat/array/groupBy.d.mts +55 -0
  31. package/dist/compat/array/groupBy.d.ts +55 -0
  32. package/dist/compat/array/groupBy.mjs +15 -0
  33. package/dist/compat/array/partition.d.mts +65 -0
  34. package/dist/compat/array/partition.d.ts +65 -0
  35. package/dist/compat/array/partition.mjs +24 -0
  36. package/dist/compat/array/pullAllWith.d.mts +59 -0
  37. package/dist/compat/array/pullAllWith.d.ts +59 -0
  38. package/dist/compat/array/pullAllWith.mjs +33 -0
  39. package/dist/compat/array/pullAt.d.mts +32 -0
  40. package/dist/compat/array/pullAt.d.ts +32 -0
  41. package/dist/compat/array/pullAt.mjs +34 -0
  42. package/dist/compat/compat.d.mts +310 -0
  43. package/dist/compat/compat.d.ts +310 -0
  44. package/dist/compat/compat.mjs +312 -0
  45. package/dist/compat/function/partial.d.mts +575 -0
  46. package/dist/compat/function/partial.d.ts +575 -0
  47. package/dist/compat/function/partial.mjs +8 -0
  48. package/dist/compat/function/partialRight.d.mts +651 -0
  49. package/dist/compat/function/partialRight.d.ts +651 -0
  50. package/dist/compat/function/partialRight.mjs +8 -0
  51. package/dist/compat/index.d.mts +16 -7
  52. package/dist/compat/index.d.ts +16 -7
  53. package/dist/compat/index.js +290 -3771
  54. package/dist/compat/index.mjs +19 -8
  55. package/dist/compat/object/defaults.mjs +7 -1
  56. package/dist/compat/object/forIn.d.mts +58 -0
  57. package/dist/compat/object/forIn.d.ts +58 -0
  58. package/dist/compat/object/forIn.mjs +16 -0
  59. package/dist/compat/object/forInRight.d.mts +58 -0
  60. package/dist/compat/object/forInRight.d.ts +58 -0
  61. package/dist/compat/object/forInRight.mjs +21 -0
  62. package/dist/compat/object/forOwn.d.mts +54 -0
  63. package/dist/compat/object/forOwn.d.ts +54 -0
  64. package/dist/compat/object/forOwn.mjs +19 -0
  65. package/dist/compat/object/forOwnRight.d.mts +54 -0
  66. package/dist/compat/object/forOwnRight.d.ts +54 -0
  67. package/dist/compat/object/forOwnRight.mjs +19 -0
  68. package/dist/compat/object/hasIn.d.mts +40 -0
  69. package/dist/compat/object/hasIn.d.ts +40 -0
  70. package/dist/compat/object/hasIn.mjs +34 -0
  71. package/dist/compat/object/toPairs.mjs +7 -2
  72. package/dist/compat/object/toPairsIn.mjs +7 -2
  73. package/dist/compat/string/repeat.d.mts +1 -1
  74. package/dist/compat/string/repeat.d.ts +1 -1
  75. package/dist/compat/string/repeat.mjs +12 -2
  76. package/dist/compat/string/words.d.mts +1 -1
  77. package/dist/compat/string/words.d.ts +1 -1
  78. package/dist/compat/string/words.mjs +2 -1
  79. package/dist/compat/toolkit.d.mts +9 -0
  80. package/dist/compat/toolkit.d.ts +9 -0
  81. package/dist/compat/toolkit.mjs +10 -0
  82. package/dist/compat/util/overEvery.d.mts +67 -0
  83. package/dist/compat/util/overEvery.d.ts +67 -0
  84. package/dist/compat/util/overEvery.mjs +23 -0
  85. package/dist/compat/util/overSome.d.mts +69 -0
  86. package/dist/compat/util/overSome.d.ts +69 -0
  87. package/dist/compat/util/overSome.mjs +23 -0
  88. package/dist/function/index.js +3 -5
  89. package/dist/function/partial.d.mts +3 -3
  90. package/dist/function/partial.d.ts +3 -3
  91. package/dist/function/partial.mjs +17 -19
  92. package/dist/function/partialRight.d.mts +3 -3
  93. package/dist/function/partialRight.d.ts +3 -3
  94. package/dist/function/partialRight.mjs +18 -20
  95. package/dist/function/throttle.mjs +0 -1
  96. package/dist/index.js +39 -42
  97. package/dist/object/index.js +15 -15
  98. package/dist/object/toCamelCaseKeys.mjs +3 -0
  99. package/dist/object/toSnakeCaseKeys.mjs +3 -0
  100. package/dist/predicate/index.js +4 -5
  101. package/dist/string/index.js +7 -8
  102. package/package.json +1 -1
  103. package/dist/_chunk/isPlainObject-Xaozpc.js +0 -93
  104. package/dist/_chunk/partialRight-B0_CSB.js +0 -50
  105. package/dist/_chunk/snakeCase-BtVEeB.js +0 -75
  106. package/dist/_chunk/toSnakeCaseKeys-BNpS71.js +0 -569
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Checks if a given path exists in an object, **including inherited properties**.
3
+ *
4
+ * You can provide the path as a single property key, an array of property keys,
5
+ * or a string representing a deep path.
6
+ *
7
+ * Unlike `has`, which only checks for own properties, `hasIn` also checks for properties
8
+ * in the prototype chain.
9
+ *
10
+ * If the path is an index and the object is an array or an arguments object, the function will verify
11
+ * if the index is valid and within the bounds of the array or arguments object, even if the array or
12
+ * arguments object is sparse (i.e., not all indexes are defined).
13
+ *
14
+ * @param {object} object - The object to query.
15
+ * @param {PropertyKey | PropertyKey[]} path - The path to check. This can be a single property key,
16
+ * an array of property keys, or a string representing a deep path.
17
+ * @returns {boolean} Returns `true` if the path exists (own or inherited), `false` otherwise.
18
+ *
19
+ * @example
20
+ *
21
+ * const obj = { a: { b: { c: 3 } } };
22
+ *
23
+ * hasIn(obj, 'a'); // true
24
+ * hasIn(obj, ['a', 'b']); // true
25
+ * hasIn(obj, ['a', 'b', 'c']); // true
26
+ * hasIn(obj, 'a.b.c'); // true
27
+ * hasIn(obj, 'a.b.d'); // false
28
+ * hasIn(obj, ['a', 'b', 'c', 'd']); // false
29
+ *
30
+ * // Example with inherited properties:
31
+ * function Rectangle() {}
32
+ * Rectangle.prototype.area = function() {};
33
+ *
34
+ * const rect = new Rectangle();
35
+ * hasIn(rect, 'area'); // true
36
+ * has(rect, 'area'); // false - has only checks own properties
37
+ */
38
+ declare function hasIn(object: unknown, path: PropertyKey | readonly PropertyKey[]): boolean;
39
+
40
+ export { hasIn };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Checks if a given path exists in an object, **including inherited properties**.
3
+ *
4
+ * You can provide the path as a single property key, an array of property keys,
5
+ * or a string representing a deep path.
6
+ *
7
+ * Unlike `has`, which only checks for own properties, `hasIn` also checks for properties
8
+ * in the prototype chain.
9
+ *
10
+ * If the path is an index and the object is an array or an arguments object, the function will verify
11
+ * if the index is valid and within the bounds of the array or arguments object, even if the array or
12
+ * arguments object is sparse (i.e., not all indexes are defined).
13
+ *
14
+ * @param {object} object - The object to query.
15
+ * @param {PropertyKey | PropertyKey[]} path - The path to check. This can be a single property key,
16
+ * an array of property keys, or a string representing a deep path.
17
+ * @returns {boolean} Returns `true` if the path exists (own or inherited), `false` otherwise.
18
+ *
19
+ * @example
20
+ *
21
+ * const obj = { a: { b: { c: 3 } } };
22
+ *
23
+ * hasIn(obj, 'a'); // true
24
+ * hasIn(obj, ['a', 'b']); // true
25
+ * hasIn(obj, ['a', 'b', 'c']); // true
26
+ * hasIn(obj, 'a.b.c'); // true
27
+ * hasIn(obj, 'a.b.d'); // false
28
+ * hasIn(obj, ['a', 'b', 'c', 'd']); // false
29
+ *
30
+ * // Example with inherited properties:
31
+ * function Rectangle() {}
32
+ * Rectangle.prototype.area = function() {};
33
+ *
34
+ * const rect = new Rectangle();
35
+ * hasIn(rect, 'area'); // true
36
+ * has(rect, 'area'); // false - has only checks own properties
37
+ */
38
+ declare function hasIn(object: unknown, path: PropertyKey | readonly PropertyKey[]): boolean;
39
+
40
+ export { hasIn };
@@ -0,0 +1,34 @@
1
+ import { isDeepKey } from '../_internal/isDeepKey.mjs';
2
+ import { isIndex } from '../_internal/isIndex.mjs';
3
+ import { isArguments } from '../predicate/isArguments.mjs';
4
+ import { toPath } from '../util/toPath.mjs';
5
+
6
+ function hasIn(object, path) {
7
+ let resolvedPath;
8
+ if (Array.isArray(path)) {
9
+ resolvedPath = path;
10
+ }
11
+ else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {
12
+ resolvedPath = toPath(path);
13
+ }
14
+ else {
15
+ resolvedPath = [path];
16
+ }
17
+ if (resolvedPath.length === 0) {
18
+ return false;
19
+ }
20
+ let current = object;
21
+ for (let i = 0; i < resolvedPath.length; i++) {
22
+ const key = resolvedPath[i];
23
+ if (current == null || !(key in Object(current))) {
24
+ const isSparseIndex = (Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length;
25
+ if (!isSparseIndex) {
26
+ return false;
27
+ }
28
+ }
29
+ current = current[key];
30
+ }
31
+ return true;
32
+ }
33
+
34
+ export { hasIn };
@@ -1,8 +1,13 @@
1
1
  import { keys } from './keys.mjs';
2
+ import { mapToEntries } from '../_internal/mapToEntries.mjs';
3
+ import { setToEntries } from '../_internal/setToEntries.mjs';
2
4
 
3
5
  function toPairs(object) {
4
- if (object instanceof Set || object instanceof Map) {
5
- return Array.from(object.entries());
6
+ if (object instanceof Set) {
7
+ return setToEntries(object);
8
+ }
9
+ if (object instanceof Map) {
10
+ return mapToEntries(object);
6
11
  }
7
12
  const keys$1 = keys(object);
8
13
  const result = new Array(keys$1.length);
@@ -1,8 +1,13 @@
1
1
  import { keysIn } from './keysIn.mjs';
2
+ import { mapToEntries } from '../_internal/mapToEntries.mjs';
3
+ import { setToEntries } from '../_internal/setToEntries.mjs';
2
4
 
3
5
  function toPairsIn(object) {
4
- if (object instanceof Set || object instanceof Map) {
5
- return Array.from(object.entries());
6
+ if (object instanceof Set) {
7
+ return setToEntries(object);
8
+ }
9
+ if (object instanceof Map) {
10
+ return mapToEntries(object);
6
11
  }
7
12
  const keys = keysIn(object);
8
13
  const result = new Array(keys.length);
@@ -12,6 +12,6 @@
12
12
  * repeat('abc', 0); // ''
13
13
  * repeat('abc', 2); // 'abcabc'
14
14
  */
15
- declare function repeat(str: string, n: number): string;
15
+ declare function repeat(str: string, n?: number, guard?: unknown): string;
16
16
 
17
17
  export { repeat };
@@ -12,6 +12,6 @@
12
12
  * repeat('abc', 0); // ''
13
13
  * repeat('abc', 2); // 'abcabc'
14
14
  */
15
- declare function repeat(str: string, n: number): string;
15
+ declare function repeat(str: string, n?: number, guard?: unknown): string;
16
16
 
17
17
  export { repeat };
@@ -1,5 +1,15 @@
1
- function repeat(str, n) {
2
- return str.repeat(n);
1
+ import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2
+ import { toInteger } from '../util/toInteger.mjs';
3
+ import { toString } from '../util/toString.mjs';
4
+
5
+ function repeat(str, n, guard) {
6
+ if (guard ? isIterateeCall(str, n, guard) : n === undefined) {
7
+ n = 1;
8
+ }
9
+ else {
10
+ n = toInteger(n);
11
+ }
12
+ return toString(str).repeat(n);
3
13
  }
4
14
 
5
15
  export { repeat };
@@ -10,6 +10,6 @@
10
10
  * // => ['fred', 'barney', 'pebbles']
11
11
  *
12
12
  */
13
- declare function words(str?: string | object, pattern?: RegExp | string): string[];
13
+ declare function words(str?: string | object, pattern?: RegExp | string, guard?: unknown): string[];
14
14
 
15
15
  export { words };
@@ -10,6 +10,6 @@
10
10
  * // => ['fred', 'barney', 'pebbles']
11
11
  *
12
12
  */
13
- declare function words(str?: string | object, pattern?: RegExp | string): string[];
13
+ declare function words(str?: string | object, pattern?: RegExp | string, guard?: unknown): string[];
14
14
 
15
15
  export { words };
@@ -1,8 +1,9 @@
1
1
  import { CASE_SPLIT_PATTERN } from '../../string/words.mjs';
2
2
  import { toString } from '../util/toString.mjs';
3
3
 
4
- function words(str, pattern = CASE_SPLIT_PATTERN) {
4
+ function words(str, pattern = CASE_SPLIT_PATTERN, guard) {
5
5
  const input = toString(str);
6
+ pattern = guard ? CASE_SPLIT_PATTERN : pattern;
6
7
  const words = Array.from(input.match(pattern) ?? []);
7
8
  return words.filter(x => x !== '');
8
9
  }
@@ -0,0 +1,9 @@
1
+ import * as compat from './compat.mjs';
2
+
3
+ type ToolkitFn = (value: any) => any;
4
+ type Compat = typeof compat;
5
+ interface Toolkit extends ToolkitFn, Compat {
6
+ }
7
+ declare const toolkit: Toolkit;
8
+
9
+ export { toolkit };
@@ -0,0 +1,9 @@
1
+ import * as compat from './compat.js';
2
+
3
+ type ToolkitFn = (value: any) => any;
4
+ type Compat = typeof compat;
5
+ interface Toolkit extends ToolkitFn, Compat {
6
+ }
7
+ declare const toolkit: Toolkit;
8
+
9
+ export { toolkit };
@@ -0,0 +1,10 @@
1
+ import * as compat from './compat.mjs';
2
+
3
+ const toolkit = ((value) => {
4
+ return value;
5
+ });
6
+ Object.assign(toolkit, compat);
7
+ toolkit.partial.placeholder = toolkit;
8
+ toolkit.partialRight.placeholder = toolkit;
9
+
10
+ export { toolkit };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Creates a predicate function that checks if a value satisfies all 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 all predicates return truthy.
12
+ *
13
+ * @example
14
+ * const func = overEvery(
15
+ * (value) => typeof value === 'string',
16
+ * (value) => value === 'hello'
17
+ * );
18
+ *
19
+ * func("hello"); // true
20
+ * func("world"); // false
21
+ * func(42); // false
22
+ */
23
+ declare function overEvery<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 all 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 all of the
34
+ * predicates return truthy for the provided values, and `false` otherwise.
35
+ *
36
+ * @example
37
+ * const func = overEvery(
38
+ * (value) => typeof value === 'string',
39
+ * (value) => value.length > 3
40
+ * );
41
+ *
42
+ * func("hello"); // true
43
+ * func("hi"); // false
44
+ * func(42); // false
45
+ *
46
+ * @example
47
+ * const func = overEvery([
48
+ * (value) => value.a > 0,
49
+ * (value) => value.b > 0
50
+ * ]);
51
+ *
52
+ * func({ a: 1, b: 2 }); // true
53
+ * func({ a: 0, b: 2 }); // false
54
+ *
55
+ * @example
56
+ * const func = overEvery(
57
+ * (a, b) => typeof a === 'string' && typeof b === 'string',
58
+ * (a, b) => a.length > 3 && b.length > 3
59
+ * );
60
+ *
61
+ * func("hello", "world"); // true
62
+ * func("hi", "world"); // false
63
+ * func(1, 10); // false
64
+ */
65
+ declare function overEvery<T>(...predicates: Array<((...args: T[]) => boolean) | ReadonlyArray<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
66
+
67
+ export { overEvery };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Creates a predicate function that checks if a value satisfies all 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 all predicates return truthy.
12
+ *
13
+ * @example
14
+ * const func = overEvery(
15
+ * (value) => typeof value === 'string',
16
+ * (value) => value === 'hello'
17
+ * );
18
+ *
19
+ * func("hello"); // true
20
+ * func("world"); // false
21
+ * func(42); // false
22
+ */
23
+ declare function overEvery<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 all 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 all of the
34
+ * predicates return truthy for the provided values, and `false` otherwise.
35
+ *
36
+ * @example
37
+ * const func = overEvery(
38
+ * (value) => typeof value === 'string',
39
+ * (value) => value.length > 3
40
+ * );
41
+ *
42
+ * func("hello"); // true
43
+ * func("hi"); // false
44
+ * func(42); // false
45
+ *
46
+ * @example
47
+ * const func = overEvery([
48
+ * (value) => value.a > 0,
49
+ * (value) => value.b > 0
50
+ * ]);
51
+ *
52
+ * func({ a: 1, b: 2 }); // true
53
+ * func({ a: 0, b: 2 }); // false
54
+ *
55
+ * @example
56
+ * const func = overEvery(
57
+ * (a, b) => typeof a === 'string' && typeof b === 'string',
58
+ * (a, b) => a.length > 3 && b.length > 3
59
+ * );
60
+ *
61
+ * func("hello", "world"); // true
62
+ * func("hi", "world"); // false
63
+ * func(1, 10); // false
64
+ */
65
+ declare function overEvery<T>(...predicates: Array<((...args: T[]) => boolean) | ReadonlyArray<(...args: T[]) => boolean>>): (...args: T[]) => boolean;
66
+
67
+ export { overEvery };
@@ -0,0 +1,23 @@
1
+ import { iteratee } from './iteratee.mjs';
2
+
3
+ function overEvery(...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 false;
10
+ }
11
+ continue;
12
+ }
13
+ for (let j = 0; j < predicate.length; ++j) {
14
+ if (!iteratee(predicate[j]).apply(this, values)) {
15
+ return false;
16
+ }
17
+ }
18
+ }
19
+ return true;
20
+ };
21
+ }
22
+
23
+ export { overEvery };
@@ -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 };
@@ -2,9 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const unary = require('../_chunk/unary-BsNWRM.js');
5
+ const unary = require('../_chunk/unary-EIEhcF.js');
6
6
  const noop = require('../_chunk/noop-2IwLUk.js');
7
- const partialRight = require('../_chunk/partialRight-B0_CSB.js');
8
7
 
9
8
  function before(n, func) {
10
9
  if (!Number.isInteger(n) || n < 0) {
@@ -76,7 +75,6 @@ function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] }
76
75
  if (Date.now() - pendingAt >= throttleMs) {
77
76
  pendingAt = Date.now();
78
77
  debounced.cancel();
79
- debounced(...args);
80
78
  }
81
79
  }
82
80
  debounced(...args);
@@ -96,12 +94,12 @@ exports.identity = unary.identity;
96
94
  exports.memoize = unary.memoize;
97
95
  exports.negate = unary.negate;
98
96
  exports.once = unary.once;
97
+ exports.partial = unary.partial;
98
+ exports.partialRight = unary.partialRight;
99
99
  exports.rest = unary.rest;
100
100
  exports.retry = unary.retry;
101
101
  exports.unary = unary.unary;
102
102
  exports.noop = noop.noop;
103
- exports.partial = partialRight.partial;
104
- exports.partialRight = partialRight.partialRight;
105
103
  exports.before = before;
106
104
  exports.curry = curry;
107
105
  exports.curryRight = curryRight;
@@ -1,4 +1,3 @@
1
- type Placeholder = typeof partialPlaceholder;
2
1
  /**
3
2
  * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
4
3
  *
@@ -544,8 +543,9 @@ declare function partial<TS extends any[], T1, T2, T3, T4, R>(func: (t1: T1, arg
544
543
  */
545
544
  declare function partial<F extends (...args: any[]) => any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType<F>;
546
545
  declare namespace partial {
547
- var placeholder: typeof partialPlaceholder;
546
+ var placeholder: typeof placeholderSymbol;
548
547
  }
549
- declare const partialPlaceholder: unique symbol;
548
+ declare const placeholderSymbol: unique symbol;
549
+ type Placeholder = typeof placeholderSymbol;
550
550
 
551
551
  export { partial };
@@ -1,4 +1,3 @@
1
- type Placeholder = typeof partialPlaceholder;
2
1
  /**
3
2
  * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
4
3
  *
@@ -544,8 +543,9 @@ declare function partial<TS extends any[], T1, T2, T3, T4, R>(func: (t1: T1, arg
544
543
  */
545
544
  declare function partial<F extends (...args: any[]) => any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType<F>;
546
545
  declare namespace partial {
547
- var placeholder: typeof partialPlaceholder;
546
+ var placeholder: typeof placeholderSymbol;
548
547
  }
549
- declare const partialPlaceholder: unique symbol;
548
+ declare const placeholderSymbol: unique symbol;
549
+ type Placeholder = typeof placeholderSymbol;
550
550
 
551
551
  export { partial };