es-toolkit 1.17.0 → 1.18.0-dev.573

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 (221) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/dist/_chunk/{index-CoqN5B.js → index-BGZDR9.js} +4 -1
  4. package/dist/_chunk/{isTypedArray-BBEkFl.js → isTypedArray-Dsrnb1.js} +1 -11
  5. package/dist/_chunk/{isFunction-aCEz9d.js → isWeakSet-BerD1A.js} +12 -2
  6. package/dist/_chunk/rest-CXt9w3.js +182 -0
  7. package/dist/_chunk/{toMerged-BGwYW5.js → toMerged-DN1PPP.js} +1 -1
  8. package/dist/_chunk/{initial-Ci2bn_.js → zipWith-CYaH1Y.js} +46 -70
  9. package/dist/array/countBy.d.mts +10 -0
  10. package/dist/array/countBy.d.ts +10 -0
  11. package/dist/array/fill.d.mts +55 -2
  12. package/dist/array/fill.d.ts +55 -2
  13. package/dist/array/flatMapDeep.d.mts +18 -0
  14. package/dist/array/flatMapDeep.d.ts +18 -0
  15. package/dist/array/flatMapDeep.mjs +7 -0
  16. package/dist/array/flattenDeep.d.mts +1 -1
  17. package/dist/array/flattenDeep.d.ts +1 -1
  18. package/dist/array/head.d.mts +14 -3
  19. package/dist/array/head.d.ts +14 -3
  20. package/dist/array/index.d.mts +9 -8
  21. package/dist/array/index.d.ts +9 -8
  22. package/dist/array/index.js +87 -58
  23. package/dist/array/index.mjs +9 -8
  24. package/dist/array/last.d.mts +23 -1
  25. package/dist/array/last.d.ts +23 -1
  26. package/dist/array/maxBy.d.mts +13 -1
  27. package/dist/array/maxBy.d.ts +13 -1
  28. package/dist/array/minBy.d.mts +13 -1
  29. package/dist/array/minBy.d.ts +13 -1
  30. package/dist/array/toFilled.d.mts +59 -2
  31. package/dist/array/toFilled.d.ts +59 -2
  32. package/dist/array/zip.d.mts +65 -7
  33. package/dist/array/zip.d.ts +65 -7
  34. package/dist/array/zipObject.d.mts +2 -4
  35. package/dist/array/zipObject.d.ts +2 -4
  36. package/dist/array/zipWith.d.mts +39 -6
  37. package/dist/array/zipWith.d.ts +39 -6
  38. package/dist/browser.global.js +1 -1
  39. package/dist/browser.global.js.map +1 -1
  40. package/dist/compat/_internal/compareValues.mjs +30 -5
  41. package/dist/compat/_internal/normalizeForCase.mjs +9 -0
  42. package/dist/compat/array/castArray.d.mts +29 -0
  43. package/dist/compat/array/castArray.d.ts +29 -0
  44. package/dist/compat/array/castArray.mjs +8 -0
  45. package/dist/compat/array/difference.d.mts +19 -0
  46. package/dist/compat/array/difference.d.ts +19 -0
  47. package/dist/compat/array/fill.d.mts +55 -2
  48. package/dist/compat/array/fill.d.ts +55 -2
  49. package/dist/compat/array/findLastIndex.d.mts +66 -0
  50. package/dist/compat/array/findLastIndex.d.ts +66 -0
  51. package/dist/compat/array/findLastIndex.mjs +33 -0
  52. package/dist/compat/array/join.d.mts +16 -0
  53. package/dist/compat/array/join.d.ts +16 -0
  54. package/dist/compat/array/join.mjs +5 -0
  55. package/dist/compat/array/orderBy.d.mts +6 -6
  56. package/dist/compat/array/orderBy.d.ts +6 -6
  57. package/dist/compat/array/orderBy.mjs +26 -18
  58. package/dist/compat/array/some.d.mts +86 -0
  59. package/dist/compat/array/some.d.ts +86 -0
  60. package/dist/compat/array/some.mjs +36 -0
  61. package/dist/compat/array/sortBy.d.mts +34 -0
  62. package/dist/compat/array/sortBy.d.ts +34 -0
  63. package/dist/compat/array/sortBy.mjs +7 -0
  64. package/dist/compat/function/ary.d.mts +11 -1
  65. package/dist/compat/function/ary.d.ts +11 -1
  66. package/dist/compat/function/attempt.d.mts +33 -0
  67. package/dist/compat/function/attempt.d.ts +33 -0
  68. package/dist/compat/function/attempt.mjs +10 -0
  69. package/dist/compat/function/bindKey.d.mts +45 -0
  70. package/dist/compat/function/bindKey.d.ts +45 -0
  71. package/dist/compat/function/bindKey.mjs +27 -0
  72. package/dist/compat/function/rearg.d.mts +18 -0
  73. package/dist/compat/function/rearg.d.ts +18 -0
  74. package/dist/compat/function/rearg.mjs +14 -0
  75. package/dist/compat/function/spread.d.mts +47 -0
  76. package/dist/compat/function/spread.d.ts +47 -0
  77. package/dist/compat/function/spread.mjs +16 -0
  78. package/dist/compat/index.d.mts +31 -10
  79. package/dist/compat/index.d.ts +31 -10
  80. package/dist/compat/index.js +401 -143
  81. package/dist/compat/index.mjs +32 -11
  82. package/dist/compat/math/max.d.mts +16 -5
  83. package/dist/compat/math/max.d.ts +16 -5
  84. package/dist/compat/math/min.d.mts +16 -4
  85. package/dist/compat/math/min.d.ts +16 -4
  86. package/dist/compat/math/parseInt.d.mts +20 -0
  87. package/dist/compat/math/parseInt.d.ts +20 -0
  88. package/dist/compat/math/parseInt.mjs +8 -0
  89. package/dist/compat/object/fromPairs.d.mts +29 -0
  90. package/dist/compat/object/fromPairs.d.ts +29 -0
  91. package/dist/compat/object/fromPairs.mjs +14 -0
  92. package/dist/compat/predicate/conforms.d.mts +22 -0
  93. package/dist/compat/predicate/conforms.d.ts +22 -0
  94. package/dist/compat/predicate/conforms.mjs +11 -0
  95. package/dist/compat/predicate/conformsTo.d.mts +29 -0
  96. package/dist/compat/predicate/conformsTo.d.ts +29 -0
  97. package/dist/compat/predicate/conformsTo.mjs +18 -0
  98. package/dist/compat/predicate/isObject.d.mts +26 -0
  99. package/dist/compat/predicate/isObject.d.ts +26 -0
  100. package/dist/compat/predicate/isObject.mjs +5 -0
  101. package/dist/compat/predicate/isRegExp.d.mts +7 -0
  102. package/dist/compat/predicate/isRegExp.d.ts +7 -0
  103. package/dist/compat/predicate/isTypedArray.d.mts +10 -0
  104. package/dist/compat/predicate/isTypedArray.d.ts +10 -0
  105. package/dist/compat/predicate/isWeakMap.d.mts +23 -0
  106. package/dist/compat/predicate/isWeakMap.d.ts +23 -0
  107. package/dist/compat/predicate/isWeakMap.mjs +7 -0
  108. package/dist/compat/predicate/isWeakSet.d.mts +23 -0
  109. package/dist/compat/predicate/isWeakSet.d.ts +23 -0
  110. package/dist/compat/predicate/isWeakSet.mjs +7 -0
  111. package/dist/compat/string/camelCase.d.mts +18 -0
  112. package/dist/compat/string/camelCase.d.ts +18 -0
  113. package/dist/compat/string/camelCase.mjs +8 -0
  114. package/dist/compat/string/endsWith.d.mts +1 -1
  115. package/dist/compat/string/endsWith.d.ts +1 -1
  116. package/dist/compat/string/endsWith.mjs +2 -2
  117. package/dist/compat/string/repeat.d.mts +17 -0
  118. package/dist/compat/string/repeat.d.ts +17 -0
  119. package/dist/compat/string/repeat.mjs +5 -0
  120. package/dist/compat/string/startsWith.d.mts +1 -1
  121. package/dist/compat/string/startsWith.d.ts +1 -1
  122. package/dist/compat/string/startsWith.mjs +2 -2
  123. package/dist/function/after.d.mts +1 -1
  124. package/dist/function/after.d.ts +1 -1
  125. package/dist/function/after.mjs +2 -2
  126. package/dist/function/before.d.mts +1 -1
  127. package/dist/function/before.d.ts +1 -1
  128. package/dist/function/before.mjs +2 -2
  129. package/dist/function/debounce.d.mts +3 -3
  130. package/dist/function/debounce.d.ts +3 -3
  131. package/dist/function/index.d.mts +1 -0
  132. package/dist/function/index.d.ts +1 -0
  133. package/dist/function/index.js +22 -180
  134. package/dist/function/index.mjs +1 -0
  135. package/dist/function/memoize.d.mts +37 -1
  136. package/dist/function/memoize.d.ts +37 -1
  137. package/dist/function/negate.d.mts +7 -1
  138. package/dist/function/negate.d.ts +7 -1
  139. package/dist/function/spread.d.mts +19 -0
  140. package/dist/function/spread.d.ts +19 -0
  141. package/dist/function/spread.mjs +7 -0
  142. package/dist/function/unary.d.mts +7 -0
  143. package/dist/function/unary.d.ts +7 -0
  144. package/dist/index.d.mts +16 -8
  145. package/dist/index.d.ts +16 -8
  146. package/dist/index.js +89 -80
  147. package/dist/index.mjs +16 -8
  148. package/dist/math/clamp.d.mts +14 -3
  149. package/dist/math/clamp.d.ts +14 -3
  150. package/dist/math/random.d.mts +13 -2
  151. package/dist/math/random.d.ts +13 -2
  152. package/dist/math/randomInt.d.mts +11 -3
  153. package/dist/math/randomInt.d.ts +11 -3
  154. package/dist/math/range.d.mts +25 -0
  155. package/dist/math/range.d.ts +25 -0
  156. package/dist/object/index.js +1 -1
  157. package/dist/object/invert.d.mts +2 -4
  158. package/dist/object/invert.d.ts +2 -4
  159. package/dist/predicate/index.d.mts +2 -0
  160. package/dist/predicate/index.d.ts +2 -0
  161. package/dist/predicate/index.js +11 -9
  162. package/dist/predicate/index.mjs +2 -0
  163. package/dist/predicate/isNotNil.mjs +1 -1
  164. package/dist/predicate/isPrimitive.d.mts +14 -0
  165. package/dist/predicate/isPrimitive.d.ts +14 -0
  166. package/dist/predicate/isRegExp.d.mts +8 -1
  167. package/dist/predicate/isRegExp.d.ts +8 -1
  168. package/dist/predicate/isSymbol.d.mts +15 -0
  169. package/dist/predicate/isSymbol.d.ts +15 -0
  170. package/dist/predicate/isTypedArray.d.mts +10 -0
  171. package/dist/predicate/isTypedArray.d.ts +10 -0
  172. package/dist/predicate/isTypedArray.mjs +1 -11
  173. package/dist/predicate/isWeakMap.d.mts +23 -0
  174. package/dist/predicate/isWeakMap.d.ts +23 -0
  175. package/dist/predicate/isWeakMap.mjs +5 -0
  176. package/dist/predicate/isWeakSet.d.mts +23 -0
  177. package/dist/predicate/isWeakSet.d.ts +23 -0
  178. package/dist/predicate/isWeakSet.mjs +5 -0
  179. package/dist/promise/delay.mjs +4 -1
  180. package/dist/promise/index.js +1 -1
  181. package/dist/promise/timeout.d.mts +7 -0
  182. package/dist/promise/timeout.d.ts +7 -0
  183. package/dist/string/capitalize.d.mts +1 -1
  184. package/dist/string/capitalize.d.ts +1 -1
  185. package/dist/string/capitalize.mjs +2 -2
  186. package/dist/string/deburr.mjs +5 -5
  187. package/dist/string/escape.d.mts +16 -0
  188. package/dist/string/escape.d.ts +16 -0
  189. package/dist/string/escape.mjs +12 -0
  190. package/dist/string/escapeRegExp.d.mts +14 -0
  191. package/dist/string/escapeRegExp.d.ts +14 -0
  192. package/dist/string/escapeRegExp.mjs +5 -0
  193. package/dist/string/index.d.mts +4 -0
  194. package/dist/string/index.d.ts +4 -0
  195. package/dist/string/index.js +53 -19
  196. package/dist/string/index.mjs +4 -0
  197. package/dist/string/kebabCase.d.mts +1 -1
  198. package/dist/string/kebabCase.d.ts +1 -1
  199. package/dist/string/kebabCase.mjs +2 -2
  200. package/dist/string/lowerCase.d.mts +1 -1
  201. package/dist/string/lowerCase.d.ts +1 -1
  202. package/dist/string/lowerCase.mjs +2 -2
  203. package/dist/string/lowerFirst.d.mts +1 -1
  204. package/dist/string/lowerFirst.d.ts +1 -1
  205. package/dist/string/lowerFirst.mjs +2 -2
  206. package/dist/string/pad.d.mts +19 -0
  207. package/dist/string/pad.d.ts +19 -0
  208. package/dist/string/pad.mjs +5 -0
  209. package/dist/string/pascalCase.d.mts +1 -1
  210. package/dist/string/pascalCase.d.ts +1 -1
  211. package/dist/string/pascalCase.mjs +2 -2
  212. package/dist/string/snakeCase.d.mts +1 -1
  213. package/dist/string/snakeCase.d.ts +1 -1
  214. package/dist/string/snakeCase.mjs +2 -2
  215. package/dist/string/unescape.d.mts +16 -0
  216. package/dist/string/unescape.d.ts +16 -0
  217. package/dist/string/unescape.mjs +12 -0
  218. package/dist/string/upperFirst.d.mts +1 -1
  219. package/dist/string/upperFirst.d.ts +1 -1
  220. package/dist/string/upperFirst.mjs +2 -2
  221. package/package.json +7 -2
@@ -13,6 +13,16 @@
13
13
  * | BigInt64Array
14
14
  * | Float32Array
15
15
  * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
16
+ *
17
+ * @example
18
+ * const arr = new Uint8Array([1, 2, 3]);
19
+ * isTypedArray(arr); // true
20
+ *
21
+ * const regularArray = [1, 2, 3];
22
+ * isTypedArray(regularArray); // false
23
+ *
24
+ * const buffer = new ArrayBuffer(16);
25
+ * isTypedArray(buffer); // false
16
26
  */
17
27
  declare function isTypedArray(x?: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
18
28
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Checks if the given value is a `WeakMap`.
3
+ *
4
+ * This function tests whether the provided value is an instance of `WeakMap`.
5
+ * It returns `true` if the value is a `WeakMap`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`.
8
+ *
9
+ * @param {unknown} value - The value to test if it is a `WeakMap`.
10
+ * @returns {value is WeakMap<WeakKey, any>} true if the value is a `WeakMap`, false otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = new WeakMap();
14
+ * const value2 = new Map();
15
+ * const value3 = new Set();
16
+ *
17
+ * console.log(isWeakMap(value1)); // true
18
+ * console.log(isWeakMap(value2)); // false
19
+ * console.log(isWeakMap(value3)); // false
20
+ */
21
+ declare function isWeakMap(value?: unknown): value is WeakMap<WeakKey, any>;
22
+
23
+ export { isWeakMap };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Checks if the given value is a `WeakMap`.
3
+ *
4
+ * This function tests whether the provided value is an instance of `WeakMap`.
5
+ * It returns `true` if the value is a `WeakMap`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`.
8
+ *
9
+ * @param {unknown} value - The value to test if it is a `WeakMap`.
10
+ * @returns {value is WeakMap<WeakKey, any>} true if the value is a `WeakMap`, false otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = new WeakMap();
14
+ * const value2 = new Map();
15
+ * const value3 = new Set();
16
+ *
17
+ * console.log(isWeakMap(value1)); // true
18
+ * console.log(isWeakMap(value2)); // false
19
+ * console.log(isWeakMap(value3)); // false
20
+ */
21
+ declare function isWeakMap(value?: unknown): value is WeakMap<WeakKey, any>;
22
+
23
+ export { isWeakMap };
@@ -0,0 +1,7 @@
1
+ import { isWeakMap as isWeakMap$1 } from '../../predicate/isWeakMap.mjs';
2
+
3
+ function isWeakMap(value) {
4
+ return isWeakMap$1(value);
5
+ }
6
+
7
+ export { isWeakMap };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Checks if the given value is a `WeakSet`.
3
+ *
4
+ * This function tests whether the provided value is an instance of `WeakSet`.
5
+ * It returns `true` if the value is a `WeakSet`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`.
8
+ *
9
+ * @param {unknown} value - The value to test if it is a `WeakSet`.
10
+ * @returns {value is WeakSet<WeakKey>} true if the value is a `WeakSet`, false otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = new WeakSet();
14
+ * const value2 = new Map();
15
+ * const value3 = new Set();
16
+ *
17
+ * console.log(isWeakSet(value1)); // true
18
+ * console.log(isWeakSet(value2)); // false
19
+ * console.log(isWeakSet(value3)); // false
20
+ */
21
+ declare function isWeakSet(value?: unknown): value is WeakSet<WeakKey>;
22
+
23
+ export { isWeakSet };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Checks if the given value is a `WeakSet`.
3
+ *
4
+ * This function tests whether the provided value is an instance of `WeakSet`.
5
+ * It returns `true` if the value is a `WeakSet`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`.
8
+ *
9
+ * @param {unknown} value - The value to test if it is a `WeakSet`.
10
+ * @returns {value is WeakSet<WeakKey>} true if the value is a `WeakSet`, false otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = new WeakSet();
14
+ * const value2 = new Map();
15
+ * const value3 = new Set();
16
+ *
17
+ * console.log(isWeakSet(value1)); // true
18
+ * console.log(isWeakSet(value2)); // false
19
+ * console.log(isWeakSet(value3)); // false
20
+ */
21
+ declare function isWeakSet(value?: unknown): value is WeakSet<WeakKey>;
22
+
23
+ export { isWeakSet };
@@ -0,0 +1,7 @@
1
+ import { isWeakSet as isWeakSet$1 } from '../../predicate/isWeakSet.mjs';
2
+
3
+ function isWeakSet(value) {
4
+ return isWeakSet$1(value);
5
+ }
6
+
7
+ export { isWeakSet };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts a string to camel case.
3
+ *
4
+ * Camel case is the naming convention in which the first word is written in lowercase and
5
+ * each subsequent word begins with a capital letter, concatenated without any separator characters.
6
+ *
7
+ * @param {string | object} str - The string that is to be changed to camel case.
8
+ * @returns {string} - The converted string to camel case.
9
+ *
10
+ * @example
11
+ * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
12
+ * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
13
+ * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
14
+ * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
15
+ */
16
+ declare function camelCase(str: string | object): string;
17
+
18
+ export { camelCase };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts a string to camel case.
3
+ *
4
+ * Camel case is the naming convention in which the first word is written in lowercase and
5
+ * each subsequent word begins with a capital letter, concatenated without any separator characters.
6
+ *
7
+ * @param {string | object} str - The string that is to be changed to camel case.
8
+ * @returns {string} - The converted string to camel case.
9
+ *
10
+ * @example
11
+ * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'
12
+ * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'
13
+ * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'
14
+ * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'
15
+ */
16
+ declare function camelCase(str: string | object): string;
17
+
18
+ export { camelCase };
@@ -0,0 +1,8 @@
1
+ import { camelCase as camelCase$1 } from '../../string/camelCase.mjs';
2
+ import { normalizeForCase } from '../_internal/normalizeForCase.mjs';
3
+
4
+ function camelCase(str) {
5
+ return camelCase$1(normalizeForCase(str));
6
+ }
7
+
8
+ export { camelCase };
@@ -15,6 +15,6 @@
15
15
  * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
16
16
  * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
17
17
  */
18
- declare const endsWith: (str: string, target: string, position?: number) => boolean;
18
+ declare function endsWith(str: string, target: string, position?: number): boolean;
19
19
 
20
20
  export { endsWith };
@@ -15,6 +15,6 @@
15
15
  * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
16
16
  * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
17
17
  */
18
- declare const endsWith: (str: string, target: string, position?: number) => boolean;
18
+ declare function endsWith(str: string, target: string, position?: number): boolean;
19
19
 
20
20
  export { endsWith };
@@ -1,5 +1,5 @@
1
- const endsWith = (str, target, position = str.length) => {
1
+ function endsWith(str, target, position = str.length) {
2
2
  return str.endsWith(target, position);
3
- };
3
+ }
4
4
 
5
5
  export { endsWith };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Repeats the given string n times.
3
+ *
4
+ * If n is less than 1, an empty string is returned, or if the string is an empty string,
5
+ * the original string is returned unchanged.
6
+ *
7
+ * @param {string} str - The string to repeat.
8
+ * @param {number} n - The number of times to repeat the string.
9
+ * @returns {string} - The repeated string, or an empty string if n is less than 1.
10
+ *
11
+ * @example
12
+ * repeat('abc', 0); // ''
13
+ * repeat('abc', 2); // 'abcabc'
14
+ */
15
+ declare function repeat(str: string, n: number): string;
16
+
17
+ export { repeat };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Repeats the given string n times.
3
+ *
4
+ * If n is less than 1, an empty string is returned, or if the string is an empty string,
5
+ * the original string is returned unchanged.
6
+ *
7
+ * @param {string} str - The string to repeat.
8
+ * @param {number} n - The number of times to repeat the string.
9
+ * @returns {string} - The repeated string, or an empty string if n is less than 1.
10
+ *
11
+ * @example
12
+ * repeat('abc', 0); // ''
13
+ * repeat('abc', 2); // 'abcabc'
14
+ */
15
+ declare function repeat(str: string, n: number): string;
16
+
17
+ export { repeat };
@@ -0,0 +1,5 @@
1
+ function repeat(str, n) {
2
+ return str.repeat(n);
3
+ }
4
+
5
+ export { repeat };
@@ -15,6 +15,6 @@
15
15
  * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
16
16
  * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
17
17
  */
18
- declare const startsWith: (str: string, target: string, position?: number) => boolean;
18
+ declare function startsWith(str: string, target: string, position?: number): boolean;
19
19
 
20
20
  export { startsWith };
@@ -15,6 +15,6 @@
15
15
  * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
16
16
  * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
17
17
  */
18
- declare const startsWith: (str: string, target: string, position?: number) => boolean;
18
+ declare function startsWith(str: string, target: string, position?: number): boolean;
19
19
 
20
20
  export { startsWith };
@@ -1,5 +1,5 @@
1
- const startsWith = (str, target, position = 0) => {
1
+ function startsWith(str, target, position = 0) {
2
2
  return str.startsWith(target, position);
3
- };
3
+ }
4
4
 
5
5
  export { startsWith };
@@ -26,6 +26,6 @@
26
26
  * // Will log 'called'.
27
27
  * afterFn()
28
28
  */
29
- declare const after: <F extends (...args: any[]) => any>(n: number, func: F) => F;
29
+ declare function after<F extends (...args: any[]) => any>(n: number, func: F): F;
30
30
 
31
31
  export { after };
@@ -26,6 +26,6 @@
26
26
  * // Will log 'called'.
27
27
  * afterFn()
28
28
  */
29
- declare const after: <F extends (...args: any[]) => any>(n: number, func: F) => F;
29
+ declare function after<F extends (...args: any[]) => any>(n: number, func: F): F;
30
30
 
31
31
  export { after };
@@ -1,4 +1,4 @@
1
- const after = (n, func) => {
1
+ function after(n, func) {
2
2
  if (!Number.isInteger(n) || n < 0) {
3
3
  throw new Error(`n must be a non-negative integer.`);
4
4
  }
@@ -9,6 +9,6 @@ const after = (n, func) => {
9
9
  }
10
10
  return undefined;
11
11
  });
12
- };
12
+ }
13
13
 
14
14
  export { after };
@@ -26,6 +26,6 @@
26
26
  * // Will not log anything.
27
27
  * beforeFn();
28
28
  */
29
- declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
29
+ declare function before<F extends (...args: any[]) => any>(n: number, func: F): F;
30
30
 
31
31
  export { before };
@@ -26,6 +26,6 @@
26
26
  * // Will not log anything.
27
27
  * beforeFn();
28
28
  */
29
- declare const before: <F extends (...args: any[]) => any>(n: number, func: F) => F;
29
+ declare function before<F extends (...args: any[]) => any>(n: number, func: F): F;
30
30
 
31
31
  export { before };
@@ -1,4 +1,4 @@
1
- const before = (n, func) => {
1
+ function before(n, func) {
2
2
  if (!Number.isInteger(n) || n < 0) {
3
3
  throw new Error('n must be a non-negative integer.');
4
4
  }
@@ -9,6 +9,6 @@ const before = (n, func) => {
9
9
  }
10
10
  return undefined;
11
11
  });
12
- };
12
+ }
13
13
 
14
14
  export { before };
@@ -9,9 +9,9 @@ interface DebounceOptions {
9
9
  * @template F - The type of function.
10
10
  * @param {F} func - The function to debounce.
11
11
  * @param {number} debounceMs - The number of milliseconds to delay.
12
- * @param {DebounceOptions} options - The options object.
12
+ * @param {DebounceOptions} options - The options object
13
13
  * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.
14
- * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
14
+ * @returns A new debounced function with a `cancel` method.
15
15
  *
16
16
  * @example
17
17
  * const debouncedFunction = debounce(() => {
@@ -36,7 +36,7 @@ interface DebounceOptions {
36
36
  * // Will cancel the debounced function call
37
37
  * controller.abort();
38
38
  */
39
- declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal }?: DebounceOptions): F & {
39
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal }?: DebounceOptions): ((...args: Parameters<F>) => void) & {
40
40
  cancel: () => void;
41
41
  };
42
42
 
@@ -9,9 +9,9 @@ interface DebounceOptions {
9
9
  * @template F - The type of function.
10
10
  * @param {F} func - The function to debounce.
11
11
  * @param {number} debounceMs - The number of milliseconds to delay.
12
- * @param {DebounceOptions} options - The options object.
12
+ * @param {DebounceOptions} options - The options object
13
13
  * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.
14
- * @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method.
14
+ * @returns A new debounced function with a `cancel` method.
15
15
  *
16
16
  * @example
17
17
  * const debouncedFunction = debounce(() => {
@@ -36,7 +36,7 @@ interface DebounceOptions {
36
36
  * // Will cancel the debounced function call
37
37
  * controller.abort();
38
38
  */
39
- declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal }?: DebounceOptions): F & {
39
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal }?: DebounceOptions): ((...args: Parameters<F>) => void) & {
40
40
  cancel: () => void;
41
41
  };
42
42
 
@@ -11,3 +11,4 @@ export { unary } from './unary.mjs';
11
11
  export { partial } from './partial.mjs';
12
12
  export { partialRight } from './partialRight.mjs';
13
13
  export { rest } from './rest.mjs';
14
+ export { spread } from './spread.mjs';
@@ -11,3 +11,4 @@ export { unary } from './unary.js';
11
11
  export { partial } from './partial.js';
12
12
  export { partialRight } from './partialRight.js';
13
13
  export { rest } from './rest.js';
14
+ export { spread } from './spread.js';
@@ -2,183 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const before = (n, func) => {
6
- if (!Number.isInteger(n) || n < 0) {
7
- throw new Error('n must be a non-negative integer.');
8
- }
9
- let counter = 0;
10
- return ((...args) => {
11
- if (++counter < n) {
12
- return func(...args);
13
- }
14
- return undefined;
15
- });
16
- };
17
-
18
- const after = (n, func) => {
19
- if (!Number.isInteger(n) || n < 0) {
20
- throw new Error(`n must be a non-negative integer.`);
21
- }
22
- let counter = 0;
23
- return ((...args) => {
24
- if (++counter >= n) {
25
- return func(...args);
26
- }
27
- return undefined;
28
- });
29
- };
30
-
31
- function debounce(func, debounceMs, { signal } = {}) {
32
- let timeoutId = null;
33
- const debounced = function (...args) {
34
- if (timeoutId !== null) {
35
- clearTimeout(timeoutId);
36
- }
37
- if (signal?.aborted) {
38
- return;
39
- }
40
- timeoutId = setTimeout(() => {
41
- func(...args);
42
- timeoutId = null;
43
- }, debounceMs);
44
- };
45
- const onAbort = function () {
46
- debounced.cancel();
47
- };
48
- debounced.cancel = function () {
49
- if (timeoutId !== null) {
50
- clearTimeout(timeoutId);
51
- timeoutId = null;
52
- }
53
- };
54
- signal?.addEventListener('abort', onAbort, { once: true });
55
- return debounced;
56
- }
57
-
58
- function noop() { }
59
-
60
- function once(func) {
61
- let called = false;
62
- let cache;
63
- return function () {
64
- if (called) {
65
- return cache;
66
- }
67
- const result = func();
68
- called = true;
69
- cache = result;
70
- return result;
71
- };
72
- }
73
-
74
- function throttle(func, throttleMs) {
75
- let lastCallTime;
76
- const throttledFunction = function (...args) {
77
- const now = Date.now();
78
- if (lastCallTime == null || now - lastCallTime >= throttleMs) {
79
- lastCallTime = now;
80
- func(...args);
81
- }
82
- };
83
- return throttledFunction;
84
- }
85
-
86
- function negate(func) {
87
- return ((...args) => !func(...args));
88
- }
89
-
90
- function memoize(fn, options = {}) {
91
- const { cache = new Map(), getCacheKey } = options;
92
- const memoizedFn = function (arg) {
93
- const key = getCacheKey ? getCacheKey(arg) : arg;
94
- if (cache.has(key)) {
95
- return cache.get(key);
96
- }
97
- const result = fn.call(this, arg);
98
- cache.set(key, result);
99
- return result;
100
- };
101
- memoizedFn.cache = cache;
102
- return memoizedFn;
103
- }
104
-
105
- function ary(func, n) {
106
- return function (...args) {
107
- return func.apply(this, args.slice(0, n));
108
- };
109
- }
110
-
111
- function unary(func) {
112
- return ary(func, 1);
113
- }
114
-
115
- function partial(func, ...partialArgs) {
116
- return function (...providedArgs) {
117
- const args = [];
118
- let startIndex = 0;
119
- for (let i = 0; i < partialArgs.length; i++) {
120
- const arg = partialArgs[i];
121
- if (arg === partial.placeholder) {
122
- args.push(providedArgs[startIndex++]);
123
- }
124
- else {
125
- args.push(arg);
126
- }
127
- }
128
- for (let i = startIndex; i < providedArgs.length; i++) {
129
- args.push(providedArgs[i]);
130
- }
131
- return func.apply(this, args);
132
- };
133
- }
134
- const partialPlaceholder = Symbol('partial.placeholder');
135
- partial.placeholder = partialPlaceholder;
136
-
137
- function partialRight(func, ...partialArgs) {
138
- return function (...providedArgs) {
139
- const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
140
- const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
141
- const args = [];
142
- let providedIndex = 0;
143
- for (let i = 0; i < rangeLength; i++) {
144
- args.push(providedArgs[providedIndex++]);
145
- }
146
- for (let i = 0; i < partialArgs.length; i++) {
147
- const arg = partialArgs[i];
148
- if (arg === partialRight.placeholder) {
149
- args.push(providedArgs[providedIndex++]);
150
- }
151
- else {
152
- args.push(arg);
153
- }
154
- }
155
- return func.apply(this, args);
156
- };
157
- }
158
- const partialRightPlaceholder = Symbol('partialRight.placeholder');
159
- partialRight.placeholder = partialRightPlaceholder;
160
-
161
- function rest(func, startIndex = func.length - 1) {
162
- return function (...args) {
163
- const rest = args.slice(startIndex);
164
- const params = args.slice(0, startIndex);
165
- while (params.length < startIndex) {
166
- params.push(undefined);
167
- }
168
- return func.apply(this, [...params, rest]);
169
- };
170
- }
171
-
172
- exports.after = after;
173
- exports.ary = ary;
174
- exports.before = before;
175
- exports.debounce = debounce;
176
- exports.memoize = memoize;
177
- exports.negate = negate;
178
- exports.noop = noop;
179
- exports.once = once;
180
- exports.partial = partial;
181
- exports.partialRight = partialRight;
182
- exports.rest = rest;
183
- exports.throttle = throttle;
184
- exports.unary = unary;
5
+ const rest = require('../_chunk/rest-CXt9w3.js');
6
+
7
+ function spread(func) {
8
+ return function (argsArr) {
9
+ return func.apply(this, argsArr);
10
+ };
11
+ }
12
+
13
+ exports.after = rest.after;
14
+ exports.ary = rest.ary;
15
+ exports.before = rest.before;
16
+ exports.debounce = rest.debounce;
17
+ exports.memoize = rest.memoize;
18
+ exports.negate = rest.negate;
19
+ exports.noop = rest.noop;
20
+ exports.once = rest.once;
21
+ exports.partial = rest.partial;
22
+ exports.partialRight = rest.partialRight;
23
+ exports.rest = rest.rest;
24
+ exports.throttle = rest.throttle;
25
+ exports.unary = rest.unary;
26
+ exports.spread = spread;
@@ -11,3 +11,4 @@ export { unary } from './unary.mjs';
11
11
  export { partial } from './partial.mjs';
12
12
  export { partialRight } from './partialRight.mjs';
13
13
  export { rest } from './rest.mjs';
14
+ export { spread } from './spread.mjs';