es-toolkit 1.35.0-dev.1202 → 1.35.0-dev.1209

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 (104) hide show
  1. package/dist/_chunk/{isPromise-ByAybB.js → isPromise-BqEEYJ.js} +126 -40
  2. package/dist/_chunk/{reverseString-D-wK2p.js → reverseString-BixeGz.js} +84 -13
  3. package/dist/_chunk/toSnakeCaseKeys-Bvb9j3.js +4578 -0
  4. package/dist/_chunk/{unary-BsNWRM.js → unary-EIEhcF.js} +46 -0
  5. package/dist/_chunk/{zip-DxZJSH.js → zipWith-CsbMsR.js} +114 -3
  6. package/dist/array/index.js +57 -126
  7. package/dist/array/take.d.mts +1 -1
  8. package/dist/array/take.d.ts +1 -1
  9. package/dist/array/take.mjs +4 -1
  10. package/dist/array/takeRight.d.mts +1 -1
  11. package/dist/array/takeRight.d.ts +1 -1
  12. package/dist/array/takeRight.mjs +5 -2
  13. package/dist/browser.global.js +1 -1
  14. package/dist/browser.global.js.map +1 -1
  15. package/dist/compat/compat.d.mts +301 -0
  16. package/dist/compat/compat.d.ts +301 -0
  17. package/dist/compat/compat.mjs +303 -0
  18. package/dist/compat/function/partial.d.mts +575 -0
  19. package/dist/compat/function/partial.d.ts +575 -0
  20. package/dist/compat/function/partial.mjs +8 -0
  21. package/dist/compat/function/partialRight.d.mts +651 -0
  22. package/dist/compat/function/partialRight.d.ts +651 -0
  23. package/dist/compat/function/partialRight.mjs +8 -0
  24. package/dist/compat/index.d.mts +10 -18
  25. package/dist/compat/index.d.ts +10 -18
  26. package/dist/compat/index.js +280 -4043
  27. package/dist/compat/index.mjs +13 -19
  28. package/dist/compat/object/defaults.mjs +7 -1
  29. package/dist/compat/string/repeat.d.mts +1 -1
  30. package/dist/compat/string/repeat.d.ts +1 -1
  31. package/dist/compat/string/repeat.mjs +12 -2
  32. package/dist/compat/string/words.d.mts +1 -1
  33. package/dist/compat/string/words.d.ts +1 -1
  34. package/dist/compat/string/words.mjs +2 -1
  35. package/dist/compat/toolkit.d.mts +9 -0
  36. package/dist/compat/toolkit.d.ts +9 -0
  37. package/dist/compat/toolkit.mjs +10 -0
  38. package/dist/function/index.js +3 -4
  39. package/dist/function/partial.d.mts +3 -3
  40. package/dist/function/partial.d.ts +3 -3
  41. package/dist/function/partial.mjs +17 -19
  42. package/dist/function/partialRight.d.mts +3 -3
  43. package/dist/function/partialRight.d.ts +3 -3
  44. package/dist/function/partialRight.mjs +18 -20
  45. package/dist/index.js +84 -87
  46. package/dist/object/index.js +15 -15
  47. package/dist/object/toCamelCaseKeys.mjs +3 -0
  48. package/dist/object/toSnakeCaseKeys.mjs +3 -0
  49. package/dist/predicate/index.js +4 -5
  50. package/dist/string/index.js +7 -8
  51. package/package.json +1 -1
  52. package/dist/_chunk/isPlainObject-Xaozpc.js +0 -93
  53. package/dist/_chunk/partialRight-B0_CSB.js +0 -50
  54. package/dist/_chunk/snakeCase-BtVEeB.js +0 -75
  55. package/dist/_chunk/toSnakeCaseKeys-BNpS71.js +0 -569
  56. package/dist/compat/_internal/copyArray.mjs +0 -12
  57. package/dist/compat/array/flatMap.d.mts +0 -20
  58. package/dist/compat/array/flatMap.d.ts +0 -20
  59. package/dist/compat/array/flatMap.mjs +0 -13
  60. package/dist/compat/array/forEachRight.d.mts +0 -106
  61. package/dist/compat/array/forEachRight.d.ts +0 -106
  62. package/dist/compat/array/forEachRight.mjs +0 -21
  63. package/dist/compat/array/partition.d.mts +0 -65
  64. package/dist/compat/array/partition.d.ts +0 -65
  65. package/dist/compat/array/partition.mjs +0 -24
  66. package/dist/compat/array/pullAllWith.d.mts +0 -59
  67. package/dist/compat/array/pullAllWith.d.ts +0 -59
  68. package/dist/compat/array/pullAllWith.mjs +0 -33
  69. package/dist/compat/array/pullAt.d.mts +0 -32
  70. package/dist/compat/array/pullAt.d.ts +0 -32
  71. package/dist/compat/array/pullAt.mjs +0 -34
  72. package/dist/compat/array/zipObject.d.mts +0 -49
  73. package/dist/compat/array/zipObject.d.ts +0 -49
  74. package/dist/compat/array/zipObject.mjs +0 -11
  75. package/dist/compat/array/zipWith.d.mts +0 -92
  76. package/dist/compat/array/zipWith.d.ts +0 -92
  77. package/dist/compat/array/zipWith.mjs +0 -20
  78. package/dist/compat/object/at.d.mts +0 -19
  79. package/dist/compat/object/at.d.ts +0 -19
  80. package/dist/compat/object/at.mjs +0 -27
  81. package/dist/compat/object/forIn.d.mts +0 -58
  82. package/dist/compat/object/forIn.d.ts +0 -58
  83. package/dist/compat/object/forIn.mjs +0 -16
  84. package/dist/compat/object/forInRight.d.mts +0 -58
  85. package/dist/compat/object/forInRight.d.ts +0 -58
  86. package/dist/compat/object/forInRight.mjs +0 -21
  87. package/dist/compat/object/forOwn.d.mts +0 -54
  88. package/dist/compat/object/forOwn.d.ts +0 -54
  89. package/dist/compat/object/forOwn.mjs +0 -19
  90. package/dist/compat/object/forOwnRight.d.mts +0 -54
  91. package/dist/compat/object/forOwnRight.d.ts +0 -54
  92. package/dist/compat/object/forOwnRight.mjs +0 -19
  93. package/dist/compat/object/hasIn.d.mts +0 -40
  94. package/dist/compat/object/hasIn.d.ts +0 -40
  95. package/dist/compat/object/hasIn.mjs +0 -34
  96. package/dist/compat/string/split.d.mts +0 -19
  97. package/dist/compat/string/split.d.ts +0 -19
  98. package/dist/compat/string/split.mjs +0 -7
  99. package/dist/compat/util/overEvery.d.mts +0 -67
  100. package/dist/compat/util/overEvery.d.ts +0 -67
  101. package/dist/compat/util/overEvery.mjs +0 -23
  102. package/dist/compat/util/overSome.d.mts +0 -69
  103. package/dist/compat/util/overSome.d.ts +0 -69
  104. package/dist/compat/util/overSome.mjs +0 -23
@@ -1,54 +0,0 @@
1
- /**
2
- * Iterates over an object's properties and calls the `iteratee` function for each property.
3
- *
4
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
- *
6
- * The `iteratee` function can terminate the iteration early by returning `false`.
7
- *
8
- * @template T - The type of the object.
9
- * @param {T} object The object to iterate over.
10
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
- * @return {T} Returns object.
12
- *
13
- * @example
14
- * function Foo() {
15
- * this.a = 1;
16
- * this.b = 2;
17
- * }
18
- *
19
- * Foo.prototype.c = 3;
20
- *
21
- * forOwn(new Foo(), function(value, key) {
22
- * console.log(key);
23
- * });
24
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
25
- */
26
- declare function forOwn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
- /**
28
- * Iterates over an object's properties and calls the `iteratee` function for each property.
29
- *
30
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
- *
32
- * The `iteratee` function can terminate the iteration early by returning `false`.
33
- *
34
- * @template T - The type of the object.
35
- * @param {T | null | undefined} object The object to iterate over.
36
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
- * @return {T | null | undefined} Returns object.
38
- *
39
- * @example
40
- * function Foo() {
41
- * this.a = 1;
42
- * this.b = 2;
43
- * }
44
- *
45
- * Foo.prototype.c = 3;
46
- *
47
- * forOwn(new Foo(), function(value, key) {
48
- * console.log(key);
49
- * });
50
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
51
- */
52
- declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
-
54
- export { forOwn };
@@ -1,54 +0,0 @@
1
- /**
2
- * Iterates over an object's properties and calls the `iteratee` function for each property.
3
- *
4
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
- *
6
- * The `iteratee` function can terminate the iteration early by returning `false`.
7
- *
8
- * @template T - The type of the object.
9
- * @param {T} object The object to iterate over.
10
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
- * @return {T} Returns object.
12
- *
13
- * @example
14
- * function Foo() {
15
- * this.a = 1;
16
- * this.b = 2;
17
- * }
18
- *
19
- * Foo.prototype.c = 3;
20
- *
21
- * forOwn(new Foo(), function(value, key) {
22
- * console.log(key);
23
- * });
24
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
25
- */
26
- declare function forOwn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
- /**
28
- * Iterates over an object's properties and calls the `iteratee` function for each property.
29
- *
30
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
- *
32
- * The `iteratee` function can terminate the iteration early by returning `false`.
33
- *
34
- * @template T - The type of the object.
35
- * @param {T | null | undefined} object The object to iterate over.
36
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
- * @return {T | null | undefined} Returns object.
38
- *
39
- * @example
40
- * function Foo() {
41
- * this.a = 1;
42
- * this.b = 2;
43
- * }
44
- *
45
- * Foo.prototype.c = 3;
46
- *
47
- * forOwn(new Foo(), function(value, key) {
48
- * console.log(key);
49
- * });
50
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
51
- */
52
- declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
-
54
- export { forOwn };
@@ -1,19 +0,0 @@
1
- import { keys } from './keys.mjs';
2
- import { identity } from '../../function/identity.mjs';
3
-
4
- function forOwn(object, iteratee = identity) {
5
- if (object == null) {
6
- return object;
7
- }
8
- const iterable = Object(object);
9
- const keys$1 = keys(object);
10
- for (let i = 0; i < keys$1.length; ++i) {
11
- const key = keys$1[i];
12
- if (iteratee(iterable[key], key, iterable) === false) {
13
- break;
14
- }
15
- }
16
- return object;
17
- }
18
-
19
- export { forOwn };
@@ -1,54 +0,0 @@
1
- /**
2
- * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
3
- *
4
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
- *
6
- * The `iteratee` function can terminate the iteration early by returning `false`.
7
- *
8
- * @template T - The type of the object.
9
- * @param {T} object The object to iterate over.
10
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
- * @return {T} Returns object.
12
- *
13
- * @example
14
- * function Foo() {
15
- * this.a = 1;
16
- * this.b = 2;
17
- * }
18
- *
19
- * Foo.prototype.c = 3;
20
- *
21
- * forOwnRight(new Foo(), function(value, key) {
22
- * console.log(key);
23
- * });
24
- * // => Logs 'b' then 'a' (iteration order is not guaranteed).
25
- */
26
- declare function forOwnRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
- /**
28
- * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
29
- *
30
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
- *
32
- * The `iteratee` function can terminate the iteration early by returning `false`.
33
- *
34
- * @template T - The type of the object.
35
- * @param {T | null | undefined} object The object to iterate over.
36
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
- * @return {T | null | undefined} Returns object.
38
- *
39
- * @example
40
- * function Foo() {
41
- * this.a = 1;
42
- * this.b = 2;
43
- * }
44
- *
45
- * Foo.prototype.c = 3;
46
- *
47
- * forOwnRight(new Foo(), function(value, key) {
48
- * console.log(key);
49
- * });
50
- * // => Logs 'b' then 'a' (iteration order is not guaranteed).
51
- */
52
- declare function forOwnRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
-
54
- export { forOwnRight };
@@ -1,54 +0,0 @@
1
- /**
2
- * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
3
- *
4
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
- *
6
- * The `iteratee` function can terminate the iteration early by returning `false`.
7
- *
8
- * @template T - The type of the object.
9
- * @param {T} object The object to iterate over.
10
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
- * @return {T} Returns object.
12
- *
13
- * @example
14
- * function Foo() {
15
- * this.a = 1;
16
- * this.b = 2;
17
- * }
18
- *
19
- * Foo.prototype.c = 3;
20
- *
21
- * forOwnRight(new Foo(), function(value, key) {
22
- * console.log(key);
23
- * });
24
- * // => Logs 'b' then 'a' (iteration order is not guaranteed).
25
- */
26
- declare function forOwnRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
- /**
28
- * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
29
- *
30
- * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
- *
32
- * The `iteratee` function can terminate the iteration early by returning `false`.
33
- *
34
- * @template T - The type of the object.
35
- * @param {T | null | undefined} object The object to iterate over.
36
- * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
- * @return {T | null | undefined} Returns object.
38
- *
39
- * @example
40
- * function Foo() {
41
- * this.a = 1;
42
- * this.b = 2;
43
- * }
44
- *
45
- * Foo.prototype.c = 3;
46
- *
47
- * forOwnRight(new Foo(), function(value, key) {
48
- * console.log(key);
49
- * });
50
- * // => Logs 'b' then 'a' (iteration order is not guaranteed).
51
- */
52
- declare function forOwnRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
-
54
- export { forOwnRight };
@@ -1,19 +0,0 @@
1
- import { keys } from './keys.mjs';
2
- import { identity } from '../../function/identity.mjs';
3
-
4
- function forOwnRight(object, iteratee = identity) {
5
- if (object == null) {
6
- return object;
7
- }
8
- const iterable = Object(object);
9
- const keys$1 = keys(object);
10
- for (let i = keys$1.length - 1; i >= 0; --i) {
11
- const key = keys$1[i];
12
- if (iteratee(iterable[key], key, iterable) === false) {
13
- break;
14
- }
15
- }
16
- return object;
17
- }
18
-
19
- export { forOwnRight };
@@ -1,40 +0,0 @@
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 };
@@ -1,40 +0,0 @@
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 };
@@ -1,34 +0,0 @@
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,19 +0,0 @@
1
- /**
2
- * Splits the input string by the specified `separator`
3
- * and returns a new array containing the split segments.
4
- *
5
- * @param {string | null | undefined} [string=''] The string to split.
6
- * @param {RegExp|string} [separator] The separator pattern to split by.
7
- * @param {number} [limit] The length to truncate results to.
8
- * @returns {Array} Returns the string segments.
9
- *
10
- * @example
11
- * split('a-b-c', '-');
12
- * // => ['a', 'b', 'c']
13
- *
14
- * split('a-b-c', '-', 2);
15
- * // => ['a', 'b']
16
- */
17
- declare function split(string?: string | null | undefined, separator?: RegExp | string, limit?: number): string[];
18
-
19
- export { split };
@@ -1,19 +0,0 @@
1
- /**
2
- * Splits the input string by the specified `separator`
3
- * and returns a new array containing the split segments.
4
- *
5
- * @param {string | null | undefined} [string=''] The string to split.
6
- * @param {RegExp|string} [separator] The separator pattern to split by.
7
- * @param {number} [limit] The length to truncate results to.
8
- * @returns {Array} Returns the string segments.
9
- *
10
- * @example
11
- * split('a-b-c', '-');
12
- * // => ['a', 'b', 'c']
13
- *
14
- * split('a-b-c', '-', 2);
15
- * // => ['a', 'b']
16
- */
17
- declare function split(string?: string | null | undefined, separator?: RegExp | string, limit?: number): string[];
18
-
19
- export { split };
@@ -1,7 +0,0 @@
1
- import { toString } from '../util/toString.mjs';
2
-
3
- function split(string = '', separator, limit) {
4
- return toString(string).split(separator, limit);
5
- }
6
-
7
- export { split };
@@ -1,67 +0,0 @@
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 };
@@ -1,67 +0,0 @@
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 };
@@ -1,23 +0,0 @@
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 };
@@ -1,69 +0,0 @@
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 };