es-toolkit 1.17.0 → 1.18.0-dev.571

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 (220) 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-CogETi.js} +11 -1
  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/isPrimitive.d.mts +14 -0
  164. package/dist/predicate/isPrimitive.d.ts +14 -0
  165. package/dist/predicate/isRegExp.d.mts +8 -1
  166. package/dist/predicate/isRegExp.d.ts +8 -1
  167. package/dist/predicate/isSymbol.d.mts +15 -0
  168. package/dist/predicate/isSymbol.d.ts +15 -0
  169. package/dist/predicate/isTypedArray.d.mts +10 -0
  170. package/dist/predicate/isTypedArray.d.ts +10 -0
  171. package/dist/predicate/isTypedArray.mjs +1 -11
  172. package/dist/predicate/isWeakMap.d.mts +23 -0
  173. package/dist/predicate/isWeakMap.d.ts +23 -0
  174. package/dist/predicate/isWeakMap.mjs +5 -0
  175. package/dist/predicate/isWeakSet.d.mts +23 -0
  176. package/dist/predicate/isWeakSet.d.ts +23 -0
  177. package/dist/predicate/isWeakSet.mjs +5 -0
  178. package/dist/promise/delay.mjs +4 -1
  179. package/dist/promise/index.js +1 -1
  180. package/dist/promise/timeout.d.mts +7 -0
  181. package/dist/promise/timeout.d.ts +7 -0
  182. package/dist/string/capitalize.d.mts +1 -1
  183. package/dist/string/capitalize.d.ts +1 -1
  184. package/dist/string/capitalize.mjs +2 -2
  185. package/dist/string/deburr.mjs +5 -5
  186. package/dist/string/escape.d.mts +16 -0
  187. package/dist/string/escape.d.ts +16 -0
  188. package/dist/string/escape.mjs +12 -0
  189. package/dist/string/escapeRegExp.d.mts +14 -0
  190. package/dist/string/escapeRegExp.d.ts +14 -0
  191. package/dist/string/escapeRegExp.mjs +5 -0
  192. package/dist/string/index.d.mts +4 -0
  193. package/dist/string/index.d.ts +4 -0
  194. package/dist/string/index.js +53 -19
  195. package/dist/string/index.mjs +4 -0
  196. package/dist/string/kebabCase.d.mts +1 -1
  197. package/dist/string/kebabCase.d.ts +1 -1
  198. package/dist/string/kebabCase.mjs +2 -2
  199. package/dist/string/lowerCase.d.mts +1 -1
  200. package/dist/string/lowerCase.d.ts +1 -1
  201. package/dist/string/lowerCase.mjs +2 -2
  202. package/dist/string/lowerFirst.d.mts +1 -1
  203. package/dist/string/lowerFirst.d.ts +1 -1
  204. package/dist/string/lowerFirst.mjs +2 -2
  205. package/dist/string/pad.d.mts +19 -0
  206. package/dist/string/pad.d.ts +19 -0
  207. package/dist/string/pad.mjs +5 -0
  208. package/dist/string/pascalCase.d.mts +1 -1
  209. package/dist/string/pascalCase.d.ts +1 -1
  210. package/dist/string/pascalCase.mjs +2 -2
  211. package/dist/string/snakeCase.d.mts +1 -1
  212. package/dist/string/snakeCase.d.ts +1 -1
  213. package/dist/string/snakeCase.mjs +2 -2
  214. package/dist/string/unescape.d.mts +16 -0
  215. package/dist/string/unescape.d.ts +16 -0
  216. package/dist/string/unescape.mjs +12 -0
  217. package/dist/string/upperFirst.d.mts +1 -1
  218. package/dist/string/upperFirst.d.ts +1 -1
  219. package/dist/string/upperFirst.mjs +2 -2
  220. package/package.json +7 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # es-toolkit Changelog
2
2
 
3
+ ## Version v1.18.0
4
+
5
+ Released on September 12th, 2024.
6
+
7
+ - Added support for [isObject](https://es-toolkit.slash.page/reference/compat/predicate/isObject.html), [findLastIndex](https://es-toolkit.slash.page/reference/compat/array/findLastIndex.html), [parseInt](https://es-toolkit.slash.page/reference/compat/math/parseInt.html), [rearg](https://es-toolkit.slash.page/reference/compat/function/rearg.html), [conforms](https://es-toolkit.slash.page/reference/compat/predicate/conforms.html), [conformsTo](https://es-toolkit.slash.page/reference/compat/predicate/conformsTo.html), [bindKey](https://es-toolkit.slash.page/reference/compat/function/bindKey.html), [some](https://es-toolkit.slash.page/reference/compat/array/some.html), [fromPairs](https://es-toolkit.slash.page/reference/compat/object/fromPairs.html), [isArrayLikeObject](https://es-toolkit.slash.page/reference/compat/predicate/isArrayLikeObject.html), [escapeRegExp](https://es-toolkit.slash.page/reference/string/escapeRegExp.html), [sortBy](https://es-toolkit.slash.page/reference/array/sortBy.html), [isWeakSet](https://es-toolkit.slash.page/reference/predicate/isWeakSet.html), [isWeakMap](https://es-toolkit.slash.page/reference/predicate/isWeakMap.html), [flatMapDeep](https://es-toolkit.slash.page/reference/array/flatMapDeep.html), [escape](https://es-toolkit.slash.page/reference/string/escape.html), [unescape](https://es-toolkit.slash.page/reference/string/unescape.html), [repeat](https://es-toolkit.slash.page/reference/compat/string/repeat.html), [pad](https://es-toolkit.slash.page/reference/compat/string/pad.html), [join](https://es-toolkit.slash.page/reference/compat/array/join.html), and [spread](https://es-toolkit.slash.page/reference/compat/function/spread.html).
8
+ - Improved performance for [deburr](https://es-toolkit.slash.page/reference/string/deburr.html).
9
+
3
10
  ## Version v1.17.0
4
11
 
5
12
  Released on August 31st, 2024.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![](./docs/public/og.png)
2
2
 
3
- # es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE) [![codecov](https://codecov.io/gh/toss/es-toolkit/graph/badge.svg?token=8N5S3AR3C7)](https://codecov.io/gh/toss/es-toolkit) [![NPM badge](https://img.shields.io/npm/v/es-toolkit?logo=npm)](https://www.npmjs.com/package/es-toolkit) [![JSR badge](https://jsr.io/badges/@es-toolkit/es-toolkit)](https://jsr.io/@es-toolkit/es-toolkit)
3
+ # es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE) [![codecov](https://codecov.io/gh/toss/es-toolkit/graph/badge.svg?token=8N5S3AR3C7)](https://codecov.io/gh/toss/es-toolkit) [![NPM badge](https://img.shields.io/npm/v/es-toolkit?logo=npm)](https://www.npmjs.com/package/es-toolkit) [![JSR badge](https://jsr.io/badges/@es-toolkit/es-toolkit)](https://jsr.io/@es-toolkit/es-toolkit) [![Discord Badge](https://discord.com/api/guilds/1281071127052943361/widget.png?style=shield)](https://discord.gg/vGXbVjP2nY)
4
4
 
5
5
  English | [한국어](https://github.com/toss/es-toolkit/blob/main/README-ko_kr.md) | [简体中文](https://github.com/toss/es-toolkit/blob/main/README-zh_hans.md) | [日本語](https://github.com/toss/es-toolkit/blob/main/README-ja_jp.md)
6
6
 
@@ -26,7 +26,10 @@ function delay(ms, { signal } = {}) {
26
26
  if (signal?.aborted) {
27
27
  return abortError();
28
28
  }
29
- const timeoutId = setTimeout(resolve, ms);
29
+ const timeoutId = setTimeout(() => {
30
+ signal?.removeEventListener('abort', abortHandler);
31
+ resolve();
32
+ }, ms);
30
33
  signal?.addEventListener('abort', abortHandler, { once: true });
31
34
  });
32
35
  }
@@ -25,17 +25,7 @@ function isPrimitive(value) {
25
25
  }
26
26
 
27
27
  function isTypedArray(x) {
28
- return (x instanceof Uint8Array ||
29
- x instanceof Uint8ClampedArray ||
30
- x instanceof Uint16Array ||
31
- x instanceof Uint32Array ||
32
- x instanceof BigUint64Array ||
33
- x instanceof Int8Array ||
34
- x instanceof Int16Array ||
35
- x instanceof Int32Array ||
36
- x instanceof BigInt64Array ||
37
- x instanceof Float32Array ||
38
- x instanceof Float64Array);
28
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
39
29
  }
40
30
 
41
31
  exports.isPlainObject = isPlainObject;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const isTypedArray = require('./isTypedArray-BBEkFl.js');
3
+ const isTypedArray = require('./isTypedArray-Dsrnb1.js');
4
4
 
5
5
  const regexpTag = '[object RegExp]';
6
6
  const stringTag = '[object String]';
@@ -234,6 +234,14 @@ function isFunction(value) {
234
234
  return typeof value === 'function';
235
235
  }
236
236
 
237
+ function isWeakMap(value) {
238
+ return value instanceof WeakMap;
239
+ }
240
+
241
+ function isWeakSet(value) {
242
+ return value instanceof WeakSet;
243
+ }
244
+
237
245
  exports.argumentsTag = argumentsTag;
238
246
  exports.booleanTag = booleanTag;
239
247
  exports.getTag = getTag;
@@ -244,5 +252,7 @@ exports.isNil = isNil;
244
252
  exports.isNotNil = isNotNil;
245
253
  exports.isNull = isNull;
246
254
  exports.isUndefined = isUndefined;
255
+ exports.isWeakMap = isWeakMap;
256
+ exports.isWeakSet = isWeakSet;
247
257
  exports.numberTag = numberTag;
248
258
  exports.stringTag = stringTag;
@@ -0,0 +1,182 @@
1
+ 'use strict';
2
+
3
+ function before(n, func) {
4
+ if (!Number.isInteger(n) || n < 0) {
5
+ throw new Error('n must be a non-negative integer.');
6
+ }
7
+ let counter = 0;
8
+ return ((...args) => {
9
+ if (++counter < n) {
10
+ return func(...args);
11
+ }
12
+ return undefined;
13
+ });
14
+ }
15
+
16
+ function after(n, func) {
17
+ if (!Number.isInteger(n) || n < 0) {
18
+ throw new Error(`n must be a non-negative integer.`);
19
+ }
20
+ let counter = 0;
21
+ return ((...args) => {
22
+ if (++counter >= n) {
23
+ return func(...args);
24
+ }
25
+ return undefined;
26
+ });
27
+ }
28
+
29
+ function debounce(func, debounceMs, { signal } = {}) {
30
+ let timeoutId = null;
31
+ const debounced = function (...args) {
32
+ if (timeoutId !== null) {
33
+ clearTimeout(timeoutId);
34
+ }
35
+ if (signal?.aborted) {
36
+ return;
37
+ }
38
+ timeoutId = setTimeout(() => {
39
+ func(...args);
40
+ timeoutId = null;
41
+ }, debounceMs);
42
+ };
43
+ const onAbort = function () {
44
+ debounced.cancel();
45
+ };
46
+ debounced.cancel = function () {
47
+ if (timeoutId !== null) {
48
+ clearTimeout(timeoutId);
49
+ timeoutId = null;
50
+ }
51
+ };
52
+ signal?.addEventListener('abort', onAbort, { once: true });
53
+ return debounced;
54
+ }
55
+
56
+ function noop() { }
57
+
58
+ function once(func) {
59
+ let called = false;
60
+ let cache;
61
+ return function () {
62
+ if (called) {
63
+ return cache;
64
+ }
65
+ const result = func();
66
+ called = true;
67
+ cache = result;
68
+ return result;
69
+ };
70
+ }
71
+
72
+ function throttle(func, throttleMs) {
73
+ let lastCallTime;
74
+ const throttledFunction = function (...args) {
75
+ const now = Date.now();
76
+ if (lastCallTime == null || now - lastCallTime >= throttleMs) {
77
+ lastCallTime = now;
78
+ func(...args);
79
+ }
80
+ };
81
+ return throttledFunction;
82
+ }
83
+
84
+ function negate(func) {
85
+ return ((...args) => !func(...args));
86
+ }
87
+
88
+ function memoize(fn, options = {}) {
89
+ const { cache = new Map(), getCacheKey } = options;
90
+ const memoizedFn = function (arg) {
91
+ const key = getCacheKey ? getCacheKey(arg) : arg;
92
+ if (cache.has(key)) {
93
+ return cache.get(key);
94
+ }
95
+ const result = fn.call(this, arg);
96
+ cache.set(key, result);
97
+ return result;
98
+ };
99
+ memoizedFn.cache = cache;
100
+ return memoizedFn;
101
+ }
102
+
103
+ function ary(func, n) {
104
+ return function (...args) {
105
+ return func.apply(this, args.slice(0, n));
106
+ };
107
+ }
108
+
109
+ function unary(func) {
110
+ return ary(func, 1);
111
+ }
112
+
113
+ function partial(func, ...partialArgs) {
114
+ return function (...providedArgs) {
115
+ const args = [];
116
+ let startIndex = 0;
117
+ for (let i = 0; i < partialArgs.length; i++) {
118
+ const arg = partialArgs[i];
119
+ if (arg === partial.placeholder) {
120
+ args.push(providedArgs[startIndex++]);
121
+ }
122
+ else {
123
+ args.push(arg);
124
+ }
125
+ }
126
+ for (let i = startIndex; i < providedArgs.length; i++) {
127
+ args.push(providedArgs[i]);
128
+ }
129
+ return func.apply(this, args);
130
+ };
131
+ }
132
+ const partialPlaceholder = Symbol('partial.placeholder');
133
+ partial.placeholder = partialPlaceholder;
134
+
135
+ function partialRight(func, ...partialArgs) {
136
+ return function (...providedArgs) {
137
+ const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
138
+ const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
139
+ const args = [];
140
+ let providedIndex = 0;
141
+ for (let i = 0; i < rangeLength; i++) {
142
+ args.push(providedArgs[providedIndex++]);
143
+ }
144
+ for (let i = 0; i < partialArgs.length; i++) {
145
+ const arg = partialArgs[i];
146
+ if (arg === partialRight.placeholder) {
147
+ args.push(providedArgs[providedIndex++]);
148
+ }
149
+ else {
150
+ args.push(arg);
151
+ }
152
+ }
153
+ return func.apply(this, args);
154
+ };
155
+ }
156
+ const partialRightPlaceholder = Symbol('partialRight.placeholder');
157
+ partialRight.placeholder = partialRightPlaceholder;
158
+
159
+ function rest(func, startIndex = func.length - 1) {
160
+ return function (...args) {
161
+ const rest = args.slice(startIndex);
162
+ const params = args.slice(0, startIndex);
163
+ while (params.length < startIndex) {
164
+ params.push(undefined);
165
+ }
166
+ return func.apply(this, [...params, rest]);
167
+ };
168
+ }
169
+
170
+ exports.after = after;
171
+ exports.ary = ary;
172
+ exports.before = before;
173
+ exports.debounce = debounce;
174
+ exports.memoize = memoize;
175
+ exports.negate = negate;
176
+ exports.noop = noop;
177
+ exports.once = once;
178
+ exports.partial = partial;
179
+ exports.partialRight = partialRight;
180
+ exports.rest = rest;
181
+ exports.throttle = throttle;
182
+ exports.unary = unary;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const isTypedArray = require('./isTypedArray-BBEkFl.js');
3
+ const isTypedArray = require('./isTypedArray-Dsrnb1.js');
4
4
 
5
5
  function omit(obj, keys) {
6
6
  const result = { ...obj };
@@ -125,6 +125,14 @@ function flatMap(arr, iteratee, depth = 1) {
125
125
  return flatten(arr.map(item => iteratee(item)), depth);
126
126
  }
127
127
 
128
+ function flattenDeep(arr) {
129
+ return flatten(arr, Infinity);
130
+ }
131
+
132
+ function flatMapDeep(arr, iteratee) {
133
+ return flattenDeep(arr.map((item) => iteratee(item)));
134
+ }
135
+
128
136
  function forEachRight(arr, callback) {
129
137
  for (let i = arr.length - 1; i >= 0; i--) {
130
138
  const element = arr[i];
@@ -144,6 +152,14 @@ function groupBy(arr, getKeyFromItem) {
144
152
  return result;
145
153
  }
146
154
 
155
+ function head(arr) {
156
+ return arr[0];
157
+ }
158
+
159
+ function initial(arr) {
160
+ return arr.slice(0, -1);
161
+ }
162
+
147
163
  function intersection(firstArr, secondArr) {
148
164
  const secondSet = new Set(secondArr);
149
165
  return firstArr.filter(item => {
@@ -164,6 +180,10 @@ function intersectionWith(firstArr, secondArr, areItemsEqual) {
164
180
  });
165
181
  }
166
182
 
183
+ function isSubset(superset, subset) {
184
+ return difference(subset, superset).length === 0;
185
+ }
186
+
167
187
  function keyBy(arr, getKeyFromItem) {
168
188
  const result = {};
169
189
  for (const item of arr) {
@@ -173,6 +193,10 @@ function keyBy(arr, getKeyFromItem) {
173
193
  return result;
174
194
  }
175
195
 
196
+ function last(arr) {
197
+ return arr[arr.length - 1];
198
+ }
199
+
176
200
  function maxBy(items, getValue) {
177
201
  let maxElement = items[0];
178
202
  let max = -Infinity;
@@ -199,34 +223,6 @@ function minBy(items, getValue) {
199
223
  return minElement;
200
224
  }
201
225
 
202
- function compareValues(a, b, order) {
203
- if (a < b) {
204
- return order === 'asc' ? -1 : 1;
205
- }
206
- if (a > b) {
207
- return order === 'asc' ? 1 : -1;
208
- }
209
- return 0;
210
- }
211
-
212
- function orderBy(arr, criteria, orders) {
213
- return arr.slice().sort((a, b) => {
214
- const ordersLength = orders.length;
215
- for (let i = 0; i < criteria.length; i++) {
216
- const order = ordersLength > i ? orders[i] : orders[ordersLength - 1];
217
- const criterion = criteria[i];
218
- const criterionIsFunction = typeof criterion === 'function';
219
- const valueA = criterionIsFunction ? criterion(a) : a[criterion];
220
- const valueB = criterionIsFunction ? criterion(b) : b[criterion];
221
- const result = compareValues(valueA, valueB, order);
222
- if (result !== 0) {
223
- return result;
224
- }
225
- }
226
- return 0;
227
- });
228
- }
229
-
230
226
  function partition(arr, isInTruthy) {
231
227
  const truthy = [];
232
228
  const falsy = [];
@@ -250,10 +246,6 @@ function pullAt(arr, indicesToRemove) {
250
246
  return removed;
251
247
  }
252
248
 
253
- function sortBy(arr, criteria) {
254
- return orderBy(arr, criteria, ['asc']);
255
- }
256
-
257
249
  function sample(arr) {
258
250
  const randomIndex = Math.floor(Math.random() * arr.length);
259
251
  return arr[randomIndex];
@@ -285,6 +277,10 @@ function shuffle(arr) {
285
277
  return result;
286
278
  }
287
279
 
280
+ function tail(arr) {
281
+ return arr.slice(1);
282
+ }
283
+
288
284
  function take(arr, count) {
289
285
  return arr.slice(0, count);
290
286
  }
@@ -316,6 +312,17 @@ function takeWhile(arr, shouldContinueTaking) {
316
312
  return result;
317
313
  }
318
314
 
315
+ function toFilled(arr, value, start = 0, end = arr.length) {
316
+ const length = arr.length;
317
+ const finalStart = Math.max(start >= 0 ? start : length + start, 0);
318
+ const finalEnd = Math.min(end >= 0 ? end : length + end, length);
319
+ const newArr = arr.slice();
320
+ for (let i = finalStart; i < finalEnd; i++) {
321
+ newArr[i] = value;
322
+ }
323
+ return newArr;
324
+ }
325
+
319
326
  function uniq(arr) {
320
327
  return Array.from(new Set(arr));
321
328
  }
@@ -391,6 +398,11 @@ function unzipWith(target, iteratee) {
391
398
  return result;
392
399
  }
393
400
 
401
+ function without(array, ...values) {
402
+ const valuesSet = new Set(values);
403
+ return array.filter(item => !valuesSet.has(item));
404
+ }
405
+
394
406
  function xor(arr1, arr2) {
395
407
  return difference(union(arr1, arr2), intersection(arr1, arr2));
396
408
  }
@@ -440,42 +452,6 @@ function zipWith(arr1, ...rest) {
440
452
  return result;
441
453
  }
442
454
 
443
- function without(array, ...values) {
444
- const valuesSet = new Set(values);
445
- return array.filter(item => !valuesSet.has(item));
446
- }
447
-
448
- function head(arr) {
449
- return arr[0];
450
- }
451
-
452
- function isSubset(superset, subset) {
453
- return difference(subset, superset).length === 0;
454
- }
455
-
456
- function tail(arr) {
457
- return arr.slice(1);
458
- }
459
-
460
- function toFilled(arr, value, start = 0, end = arr.length) {
461
- const length = arr.length;
462
- const finalStart = Math.max(start >= 0 ? start : length + start, 0);
463
- const finalEnd = Math.min(end >= 0 ? end : length + end, length);
464
- const newArr = arr.slice();
465
- for (let i = finalStart; i < finalEnd; i++) {
466
- newArr[i] = value;
467
- }
468
- return newArr;
469
- }
470
-
471
- function last(arr) {
472
- return arr[arr.length - 1];
473
- }
474
-
475
- function initial(arr) {
476
- return arr.slice(0, -1);
477
- }
478
-
479
455
  exports.at = at;
480
456
  exports.chunk = chunk;
481
457
  exports.compact = compact;
@@ -489,7 +465,9 @@ exports.dropRightWhile = dropRightWhile;
489
465
  exports.dropWhile = dropWhile;
490
466
  exports.fill = fill;
491
467
  exports.flatMap = flatMap;
468
+ exports.flatMapDeep = flatMapDeep;
492
469
  exports.flatten = flatten;
470
+ exports.flattenDeep = flattenDeep;
493
471
  exports.forEachRight = forEachRight;
494
472
  exports.groupBy = groupBy;
495
473
  exports.head = head;
@@ -502,13 +480,11 @@ exports.keyBy = keyBy;
502
480
  exports.last = last;
503
481
  exports.maxBy = maxBy;
504
482
  exports.minBy = minBy;
505
- exports.orderBy = orderBy;
506
483
  exports.partition = partition;
507
484
  exports.pullAt = pullAt;
508
485
  exports.sample = sample;
509
486
  exports.sampleSize = sampleSize;
510
487
  exports.shuffle = shuffle;
511
- exports.sortBy = sortBy;
512
488
  exports.tail = tail;
513
489
  exports.take = take;
514
490
  exports.takeRight = takeRight;
@@ -14,6 +14,16 @@
14
14
  * @param {(item: T) => K} mapper - The transformation function that maps each item to a key.
15
15
  * @returns {Record<K, number>} An object containing the transformed items as keys and the
16
16
  * counts as values.
17
+ *
18
+ * @example
19
+ * const array = ['a', 'b', 'c', 'a', 'b', 'a'];
20
+ * const result = countBy(array, x => x);
21
+ * // result will be { a: 3, b: 2, c: 1 }
22
+ *
23
+ * @example
24
+ * const array = [1, 2, 3, 4, 5];
25
+ * const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
26
+ * // result will be { odd: 3, even: 2 }
17
27
  */
18
28
  declare function countBy<T, K extends PropertyKey>(arr: readonly T[], mapper: (item: T) => K): Record<K, number>;
19
29
 
@@ -14,6 +14,16 @@
14
14
  * @param {(item: T) => K} mapper - The transformation function that maps each item to a key.
15
15
  * @returns {Record<K, number>} An object containing the transformed items as keys and the
16
16
  * counts as values.
17
+ *
18
+ * @example
19
+ * const array = ['a', 'b', 'c', 'a', 'b', 'a'];
20
+ * const result = countBy(array, x => x);
21
+ * // result will be { a: 3, b: 2, c: 1 }
22
+ *
23
+ * @example
24
+ * const array = [1, 2, 3, 4, 5];
25
+ * const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');
26
+ * // result will be { odd: 3, even: 2 }
17
27
  */
18
28
  declare function countBy<T, K extends PropertyKey>(arr: readonly T[], mapper: (item: T) => K): Record<K, number>;
19
29
 
@@ -1,3 +1,58 @@
1
+ /**
2
+ * Fills the whole array with a specified value.
3
+ *
4
+ * This function mutates the original array and replaces its elements with the provided value, starting from the specified
5
+ * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
6
+ * entire array.
7
+ *
8
+ * @template T, U
9
+ * @param {Array<T | U>} array - The array to fill.
10
+ * @param {U} value - The value to fill the array with.
11
+ * @returns {Array<T | U>} The array with the filled values.
12
+ *
13
+ * @example
14
+ * const array = [1, 2, 3];
15
+ * const result = fill(array, 'a');
16
+ * // => ['a', 'a', 'a']
17
+ *
18
+ * const result = fill(Array(3), 2);
19
+ * // => [2, 2, 2]
20
+ *
21
+ * const result = fill([4, 6, 8, 10], '*', 1, 3);
22
+ * // => [4, '*', '*', 10]
23
+ *
24
+ * const result = fill(array, '*', -2, -1);
25
+ * // => [1, '*', 3]
26
+ */
27
+ declare function fill<T>(array: unknown[], value: T): T[];
28
+ /**
29
+ * Fills elements of an array with a specified value from the start position up to the end of the array.
30
+ *
31
+ * This function mutates the original array and replaces its elements with the provided value, starting from the specified
32
+ * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
33
+ * entire array.
34
+ *
35
+ * @template T, U
36
+ * @param {Array<T | U>} array - The array to fill.
37
+ * @param {U} value - The value to fill the array with.
38
+ * @param {number} [start=0] - The start position. Defaults to 0.
39
+ * @returns {Array<T | U>} The array with the filled values.
40
+ *
41
+ * @example
42
+ * const array = [1, 2, 3];
43
+ * const result = fill(array, 'a');
44
+ * // => ['a', 'a', 'a']
45
+ *
46
+ * const result = fill(Array(3), 2);
47
+ * // => [2, 2, 2]
48
+ *
49
+ * const result = fill([4, 6, 8, 10], '*', 1, 3);
50
+ * // => [4, '*', '*', 10]
51
+ *
52
+ * const result = fill(array, '*', -2, -1);
53
+ * // => [1, '*', 3]
54
+ */
55
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
1
56
  /**
2
57
  * Fills elements of an array with a specified value from the start position up to, but not including, the end position.
3
58
  *
@@ -26,8 +81,6 @@
26
81
  * const result = fill(array, '*', -2, -1);
27
82
  * // => [1, '*', 3]
28
83
  */
29
- declare function fill<T>(array: unknown[], value: T): T[];
30
- declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
31
84
  declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
32
85
 
33
86
  export { fill };
@@ -1,3 +1,58 @@
1
+ /**
2
+ * Fills the whole array with a specified value.
3
+ *
4
+ * This function mutates the original array and replaces its elements with the provided value, starting from the specified
5
+ * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
6
+ * entire array.
7
+ *
8
+ * @template T, U
9
+ * @param {Array<T | U>} array - The array to fill.
10
+ * @param {U} value - The value to fill the array with.
11
+ * @returns {Array<T | U>} The array with the filled values.
12
+ *
13
+ * @example
14
+ * const array = [1, 2, 3];
15
+ * const result = fill(array, 'a');
16
+ * // => ['a', 'a', 'a']
17
+ *
18
+ * const result = fill(Array(3), 2);
19
+ * // => [2, 2, 2]
20
+ *
21
+ * const result = fill([4, 6, 8, 10], '*', 1, 3);
22
+ * // => [4, '*', '*', 10]
23
+ *
24
+ * const result = fill(array, '*', -2, -1);
25
+ * // => [1, '*', 3]
26
+ */
27
+ declare function fill<T>(array: unknown[], value: T): T[];
28
+ /**
29
+ * Fills elements of an array with a specified value from the start position up to the end of the array.
30
+ *
31
+ * This function mutates the original array and replaces its elements with the provided value, starting from the specified
32
+ * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
33
+ * entire array.
34
+ *
35
+ * @template T, U
36
+ * @param {Array<T | U>} array - The array to fill.
37
+ * @param {U} value - The value to fill the array with.
38
+ * @param {number} [start=0] - The start position. Defaults to 0.
39
+ * @returns {Array<T | U>} The array with the filled values.
40
+ *
41
+ * @example
42
+ * const array = [1, 2, 3];
43
+ * const result = fill(array, 'a');
44
+ * // => ['a', 'a', 'a']
45
+ *
46
+ * const result = fill(Array(3), 2);
47
+ * // => [2, 2, 2]
48
+ *
49
+ * const result = fill([4, 6, 8, 10], '*', 1, 3);
50
+ * // => [4, '*', '*', 10]
51
+ *
52
+ * const result = fill(array, '*', -2, -1);
53
+ * // => [1, '*', 3]
54
+ */
55
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
1
56
  /**
2
57
  * Fills elements of an array with a specified value from the start position up to, but not including, the end position.
3
58
  *
@@ -26,8 +81,6 @@
26
81
  * const result = fill(array, '*', -2, -1);
27
82
  * // => [1, '*', 3]
28
83
  */
29
- declare function fill<T>(array: unknown[], value: T): T[];
30
- declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
31
84
  declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
32
85
 
33
86
  export { fill };
@@ -0,0 +1,18 @@
1
+ import { ExtractNestedArrayType } from './flattenDeep.mjs';
2
+
3
+ /**
4
+ * Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
5
+ *
6
+ * @template T - The type of elements within the array.
7
+ * @template U - The type of elements within the returned array from the iteratee function.
8
+ * @param {T[]} arr - The array to flatten.
9
+ * @param {(item: T) => U} iteratee - The function that produces the new array elements.
10
+ * @returns {Array<ExtractNestedArrayType<U>>} A new array that has been flattened.
11
+ *
12
+ * @example
13
+ * const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
14
+ * // [1, 1, 2, 2, 3, 3]
15
+ */
16
+ declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T) => U): Array<ExtractNestedArrayType<U>>;
17
+
18
+ export { flatMapDeep };
@@ -0,0 +1,18 @@
1
+ import { ExtractNestedArrayType } from './flattenDeep.js';
2
+
3
+ /**
4
+ * Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
5
+ *
6
+ * @template T - The type of elements within the array.
7
+ * @template U - The type of elements within the returned array from the iteratee function.
8
+ * @param {T[]} arr - The array to flatten.
9
+ * @param {(item: T) => U} iteratee - The function that produces the new array elements.
10
+ * @returns {Array<ExtractNestedArrayType<U>>} A new array that has been flattened.
11
+ *
12
+ * @example
13
+ * const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
14
+ * // [1, 1, 2, 2, 3, 3]
15
+ */
16
+ declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T) => U): Array<ExtractNestedArrayType<U>>;
17
+
18
+ export { flatMapDeep };