es-toolkit 0.0.1

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 (303) hide show
  1. package/.vscode/extensions.json +7 -0
  2. package/.vscode/settings.json +10 -0
  3. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  4. package/.yarn/sdks/eslint/lib/api.js +20 -0
  5. package/.yarn/sdks/eslint/lib/unsupported-api.js +20 -0
  6. package/.yarn/sdks/eslint/package.json +14 -0
  7. package/.yarn/sdks/integrations.yml +5 -0
  8. package/.yarn/sdks/prettier/bin/prettier.cjs +20 -0
  9. package/.yarn/sdks/prettier/index.cjs +20 -0
  10. package/.yarn/sdks/prettier/package.json +7 -0
  11. package/.yarn/sdks/typescript/bin/tsc +20 -0
  12. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  13. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  14. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  15. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  16. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  17. package/.yarn/sdks/typescript/package.json +10 -0
  18. package/babel.config.js +6 -0
  19. package/coverage/.tmp/coverage-0.json +1 -0
  20. package/coverage/.tmp/coverage-1.json +1 -0
  21. package/coverage/.tmp/coverage-10.json +1 -0
  22. package/coverage/.tmp/coverage-11.json +1 -0
  23. package/coverage/.tmp/coverage-12.json +1 -0
  24. package/coverage/.tmp/coverage-13.json +1 -0
  25. package/coverage/.tmp/coverage-14.json +1 -0
  26. package/coverage/.tmp/coverage-15.json +1 -0
  27. package/coverage/.tmp/coverage-16.json +1 -0
  28. package/coverage/.tmp/coverage-17.json +1 -0
  29. package/coverage/.tmp/coverage-18.json +1 -0
  30. package/coverage/.tmp/coverage-19.json +1 -0
  31. package/coverage/.tmp/coverage-2.json +1 -0
  32. package/coverage/.tmp/coverage-20.json +1 -0
  33. package/coverage/.tmp/coverage-21.json +1 -0
  34. package/coverage/.tmp/coverage-22.json +1 -0
  35. package/coverage/.tmp/coverage-23.json +1 -0
  36. package/coverage/.tmp/coverage-24.json +1 -0
  37. package/coverage/.tmp/coverage-25.json +1 -0
  38. package/coverage/.tmp/coverage-26.json +1 -0
  39. package/coverage/.tmp/coverage-27.json +1 -0
  40. package/coverage/.tmp/coverage-28.json +1 -0
  41. package/coverage/.tmp/coverage-29.json +1 -0
  42. package/coverage/.tmp/coverage-3.json +1 -0
  43. package/coverage/.tmp/coverage-30.json +1 -0
  44. package/coverage/.tmp/coverage-4.json +1 -0
  45. package/coverage/.tmp/coverage-5.json +1 -0
  46. package/coverage/.tmp/coverage-6.json +1 -0
  47. package/coverage/.tmp/coverage-7.json +1 -0
  48. package/coverage/.tmp/coverage-8.json +1 -0
  49. package/coverage/.tmp/coverage-9.json +1 -0
  50. package/dist/array/chunk.d.ts +8 -0
  51. package/dist/array/chunk.spec.d.ts +1 -0
  52. package/dist/array/difference.d.ts +7 -0
  53. package/dist/array/difference.spec.d.ts +1 -0
  54. package/dist/array/differenceBy.d.ts +8 -0
  55. package/dist/array/differenceBy.spec.d.ts +1 -0
  56. package/dist/array/differenceWith.d.ts +8 -0
  57. package/dist/array/differenceWith.spec.d.ts +1 -0
  58. package/dist/array/drop.d.ts +7 -0
  59. package/dist/array/drop.spec.d.ts +1 -0
  60. package/dist/array/dropRight.d.ts +7 -0
  61. package/dist/array/dropRight.spec.d.ts +1 -0
  62. package/dist/array/dropRightWhile.d.ts +7 -0
  63. package/dist/array/dropRightWhile.spec.d.ts +1 -0
  64. package/dist/array/dropWhile.d.ts +7 -0
  65. package/dist/array/dropWhile.spec.d.ts +1 -0
  66. package/dist/array/groupBy.d.ts +1 -0
  67. package/dist/array/index.d.ts +30 -0
  68. package/dist/array/index.js +778 -0
  69. package/dist/array/intersection.d.ts +11 -0
  70. package/dist/array/intersection.spec.d.ts +1 -0
  71. package/dist/array/intersectionBy.d.ts +12 -0
  72. package/dist/array/intersectionBy.spec.d.ts +1 -0
  73. package/dist/array/intersectionWith.d.ts +12 -0
  74. package/dist/array/intersectionWith.spec.d.ts +1 -0
  75. package/dist/array/partition.d.ts +8 -0
  76. package/dist/array/partition.spec.d.ts +1 -0
  77. package/dist/array/sample.d.ts +7 -0
  78. package/dist/array/sample.spec.d.ts +1 -0
  79. package/dist/array/shuffle.d.ts +7 -0
  80. package/dist/array/shuffle.spec.d.ts +1 -0
  81. package/dist/array/take.d.ts +23 -0
  82. package/dist/array/take.spec.d.ts +1 -0
  83. package/dist/array/takeRight.d.ts +23 -0
  84. package/dist/array/takeRight.spec.d.ts +1 -0
  85. package/dist/array/takeRightWhile.d.ts +18 -0
  86. package/dist/array/takeRightWhile.spec.d.ts +1 -0
  87. package/dist/array/takeWhile.d.ts +19 -0
  88. package/dist/array/takeWhile.spec.d.ts +1 -0
  89. package/dist/array/union.d.ts +10 -0
  90. package/dist/array/union.spec.d.ts +1 -0
  91. package/dist/array/unionBy.d.ts +24 -0
  92. package/dist/array/unionBy.spec.d.ts +1 -0
  93. package/dist/array/unionWith.d.ts +14 -0
  94. package/dist/array/unionWith.spec.d.ts +1 -0
  95. package/dist/array/uniq.d.ts +14 -0
  96. package/dist/array/uniq.spec.d.ts +1 -0
  97. package/dist/array/uniqBy.d.ts +12 -0
  98. package/dist/array/uniqBy.spec.d.ts +1 -0
  99. package/dist/array/uniqWith.d.ts +12 -0
  100. package/dist/array/uniqWith.spec.d.ts +1 -0
  101. package/dist/array/xor.d.ts +19 -0
  102. package/dist/array/xor.spec.d.ts +1 -0
  103. package/dist/array/xorBy.d.ts +20 -0
  104. package/dist/array/xorBy.spec.d.ts +1 -0
  105. package/dist/array/xorWith.d.ts +19 -0
  106. package/dist/array/xorWith.spec.d.ts +1 -0
  107. package/dist/array/zip.d.ts +13 -0
  108. package/dist/array/zip.spec.d.ts +1 -0
  109. package/dist/array/zipWith.d.ts +9 -0
  110. package/dist/array/zipWith.spec.d.ts +1 -0
  111. package/dist/function/debounce.d.ts +24 -0
  112. package/dist/function/debounce.spec.d.ts +1 -0
  113. package/dist/function/index.d.ts +3 -0
  114. package/dist/function/index.js +113 -0
  115. package/dist/function/once.d.ts +18 -0
  116. package/dist/function/once.spec.d.ts +1 -0
  117. package/dist/function/throttle.d.ts +26 -0
  118. package/dist/function/throttle.spec.d.ts +1 -0
  119. package/dist/index.d.ts +6 -0
  120. package/dist/index.js +1111 -0
  121. package/dist/math/clamp.d.ts +11 -0
  122. package/dist/math/clamp.spec.d.ts +1 -0
  123. package/dist/math/index.d.ts +3 -0
  124. package/dist/math/index.js +63 -0
  125. package/dist/math/round.d.ts +13 -0
  126. package/dist/math/round.spec.d.ts +1 -0
  127. package/dist/math/sum.d.ts +13 -0
  128. package/dist/math/sum.spec.d.ts +1 -0
  129. package/dist/object/index.d.ts +4 -0
  130. package/dist/object/index.js +176 -0
  131. package/dist/object/omit.d.ts +7 -0
  132. package/dist/object/omit.spec.d.ts +1 -0
  133. package/dist/object/omitBy.d.ts +1 -0
  134. package/dist/object/pick.d.ts +7 -0
  135. package/dist/object/pick.spec.d.ts +1 -0
  136. package/dist/object/pickBy.d.ts +1 -0
  137. package/dist/predicate/index.d.ts +4 -0
  138. package/dist/predicate/index.js +50 -0
  139. package/dist/predicate/isNil.d.ts +6 -0
  140. package/dist/predicate/isNil.spec.d.ts +1 -0
  141. package/dist/predicate/isNotNil.d.ts +12 -0
  142. package/dist/predicate/isNotNil.spec.d.ts +1 -0
  143. package/dist/predicate/isNull.d.ts +6 -0
  144. package/dist/predicate/isNull.spec.d.ts +1 -0
  145. package/dist/predicate/isUndefined.d.ts +6 -0
  146. package/dist/predicate/isUndefined.spec.d.ts +1 -0
  147. package/dist/promise/delay.d.ts +6 -0
  148. package/dist/promise/delay.spec.d.ts +1 -0
  149. package/dist/promise/index.d.ts +1 -0
  150. package/dist/promise/index.js +16 -0
  151. package/esm/_virtual/_rollupPluginBabelHelpers.mjs +163 -0
  152. package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +114 -0
  153. package/esm/array/chunk.mjs +35 -0
  154. package/esm/array/difference.mjs +13 -0
  155. package/esm/array/differenceBy.mjs +17 -0
  156. package/esm/array/differenceWith.mjs +16 -0
  157. package/esm/array/drop.mjs +11 -0
  158. package/esm/array/dropRight.mjs +11 -0
  159. package/esm/array/dropRightWhile.mjs +15 -0
  160. package/esm/array/dropWhile.mjs +14 -0
  161. package/esm/array/groupBy.mjs +5 -0
  162. package/esm/array/index.mjs +30 -0
  163. package/esm/array/intersection.mjs +17 -0
  164. package/esm/array/intersectionBy.mjs +21 -0
  165. package/esm/array/intersectionWith.mjs +20 -0
  166. package/esm/array/partition.mjs +32 -0
  167. package/esm/array/sample.mjs +12 -0
  168. package/esm/array/shuffle.mjs +20 -0
  169. package/esm/array/take.mjs +27 -0
  170. package/esm/array/takeRight.mjs +30 -0
  171. package/esm/array/takeRightWhile.mjs +27 -0
  172. package/esm/array/takeWhile.mjs +41 -0
  173. package/esm/array/union.mjs +19 -0
  174. package/esm/array/unionBy.mjs +38 -0
  175. package/esm/array/unionWith.mjs +21 -0
  176. package/esm/array/uniq.mjs +18 -0
  177. package/esm/array/uniqBy.mjs +20 -0
  178. package/esm/array/uniqWith.mjs +39 -0
  179. package/esm/array/xor.mjs +27 -0
  180. package/esm/array/xorBy.mjs +30 -0
  181. package/esm/array/xorWith.mjs +29 -0
  182. package/esm/array/zip.mjs +40 -0
  183. package/esm/array/zipWith.mjs +31 -0
  184. package/esm/function/debounce.mjs +39 -0
  185. package/esm/function/index.mjs +3 -0
  186. package/esm/function/once.mjs +32 -0
  187. package/esm/function/throttle.mjs +38 -0
  188. package/esm/index.mjs +45 -0
  189. package/esm/math/clamp.mjs +18 -0
  190. package/esm/math/index.mjs +3 -0
  191. package/esm/math/round.mjs +19 -0
  192. package/esm/math/sum.mjs +22 -0
  193. package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +115 -0
  194. package/esm/object/index.mjs +4 -0
  195. package/esm/object/omit.mjs +26 -0
  196. package/esm/object/omitBy.mjs +5 -0
  197. package/esm/object/pick.mjs +26 -0
  198. package/esm/object/pickBy.mjs +5 -0
  199. package/esm/predicate/index.mjs +4 -0
  200. package/esm/predicate/isNil.mjs +10 -0
  201. package/esm/predicate/isNotNil.mjs +16 -0
  202. package/esm/predicate/isNull.mjs +10 -0
  203. package/esm/predicate/isUndefined.mjs +10 -0
  204. package/esm/promise/delay.mjs +12 -0
  205. package/esm/promise/index.mjs +1 -0
  206. package/package.json +94 -0
  207. package/rollup.config.js +5 -0
  208. package/src/array/chunk.spec.ts +27 -0
  209. package/src/array/chunk.ts +24 -0
  210. package/src/array/difference.spec.ts +10 -0
  211. package/src/array/difference.ts +11 -0
  212. package/src/array/differenceBy.spec.ts +9 -0
  213. package/src/array/differenceBy.ts +14 -0
  214. package/src/array/differenceWith.spec.ts +8 -0
  215. package/src/array/differenceWith.ts +14 -0
  216. package/src/array/drop.spec.ts +9 -0
  217. package/src/array/drop.ts +9 -0
  218. package/src/array/dropRight.spec.ts +9 -0
  219. package/src/array/dropRight.ts +9 -0
  220. package/src/array/dropRightWhile.spec.ts +16 -0
  221. package/src/array/dropRightWhile.ts +13 -0
  222. package/src/array/dropWhile.spec.ts +14 -0
  223. package/src/array/dropWhile.ts +10 -0
  224. package/src/array/groupBy.ts +3 -0
  225. package/src/array/index.ts +30 -0
  226. package/src/array/intersection.spec.ts +11 -0
  227. package/src/array/intersection.ts +15 -0
  228. package/src/array/intersectionBy.spec.ts +9 -0
  229. package/src/array/intersectionBy.ts +18 -0
  230. package/src/array/intersectionWith.spec.ts +9 -0
  231. package/src/array/intersectionWith.ts +18 -0
  232. package/src/array/partition.spec.ts +23 -0
  233. package/src/array/partition.ts +21 -0
  234. package/src/array/sample.spec.ts +11 -0
  235. package/src/array/sample.ts +10 -0
  236. package/src/array/shuffle.spec.ts +11 -0
  237. package/src/array/shuffle.ts +18 -0
  238. package/src/array/take.spec.ts +25 -0
  239. package/src/array/take.ts +25 -0
  240. package/src/array/takeRight.spec.ts +25 -0
  241. package/src/array/takeRight.ts +29 -0
  242. package/src/array/takeRightWhile.spec.ts +16 -0
  243. package/src/array/takeRightWhile.ts +26 -0
  244. package/src/array/takeWhile.spec.ts +34 -0
  245. package/src/array/takeWhile.ts +31 -0
  246. package/src/array/union.spec.ts +10 -0
  247. package/src/array/union.ts +14 -0
  248. package/src/array/unionBy.spec.ts +12 -0
  249. package/src/array/unionBy.ts +35 -0
  250. package/src/array/unionWith.spec.ts +23 -0
  251. package/src/array/unionWith.ts +18 -0
  252. package/src/array/uniq.spec.ts +8 -0
  253. package/src/array/uniq.ts +16 -0
  254. package/src/array/uniqBy.spec.ts +8 -0
  255. package/src/array/uniqBy.ts +17 -0
  256. package/src/array/uniqWith.spec.ts +16 -0
  257. package/src/array/uniqWith.ts +29 -0
  258. package/src/array/xor.spec.ts +13 -0
  259. package/src/array/xor.ts +25 -0
  260. package/src/array/xorBy.spec.ts +16 -0
  261. package/src/array/xorBy.ts +29 -0
  262. package/src/array/xorWith.spec.ts +16 -0
  263. package/src/array/xorWith.ts +28 -0
  264. package/src/array/zip.spec.ts +14 -0
  265. package/src/array/zip.ts +34 -0
  266. package/src/array/zipWith.spec.ts +13 -0
  267. package/src/array/zipWith.ts +23 -0
  268. package/src/function/debounce.spec.ts +76 -0
  269. package/src/function/debounce.ts +42 -0
  270. package/src/function/index.ts +3 -0
  271. package/src/function/once.spec.ts +31 -0
  272. package/src/function/once.ts +34 -0
  273. package/src/function/throttle.spec.ts +32 -0
  274. package/src/function/throttle.ts +39 -0
  275. package/src/index.ts +6 -0
  276. package/src/math/clamp.spec.ts +18 -0
  277. package/src/math/clamp.ts +17 -0
  278. package/src/math/index.ts +3 -0
  279. package/src/math/round.spec.ts +53 -0
  280. package/src/math/round.ts +16 -0
  281. package/src/math/sum.spec.ts +29 -0
  282. package/src/math/sum.ts +17 -0
  283. package/src/object/index.ts +4 -0
  284. package/src/object/omit.spec.ts +10 -0
  285. package/src/object/omit.ts +15 -0
  286. package/src/object/omitBy.ts +3 -0
  287. package/src/object/pick.spec.ts +10 -0
  288. package/src/object/pick.ts +15 -0
  289. package/src/object/pickBy.ts +3 -0
  290. package/src/predicate/index.ts +4 -0
  291. package/src/predicate/isNil.spec.ts +23 -0
  292. package/src/predicate/isNil.ts +8 -0
  293. package/src/predicate/isNotNil.spec.ts +29 -0
  294. package/src/predicate/isNotNil.ts +14 -0
  295. package/src/predicate/isNull.spec.ts +23 -0
  296. package/src/predicate/isNull.ts +8 -0
  297. package/src/predicate/isUndefined.spec.ts +23 -0
  298. package/src/predicate/isUndefined.ts +8 -0
  299. package/src/promise/delay.spec.ts +13 -0
  300. package/src/promise/delay.ts +10 -0
  301. package/src/promise/index.ts +1 -0
  302. package/tsconfig.json +12 -0
  303. package/vitest.config.mts +13 -0
package/dist/index.js ADDED
@@ -0,0 +1,1111 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _iterableToArrayLimit(r, l) {
6
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
7
+ if (null != t) {
8
+ var e,
9
+ n,
10
+ i,
11
+ u,
12
+ a = [],
13
+ f = !0,
14
+ o = !1;
15
+ try {
16
+ if (i = (t = t.call(r)).next, 0 === l) {
17
+ if (Object(t) !== t) return;
18
+ f = !1;
19
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
20
+ } catch (r) {
21
+ o = !0, n = r;
22
+ } finally {
23
+ try {
24
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
25
+ } finally {
26
+ if (o) throw n;
27
+ }
28
+ }
29
+ return a;
30
+ }
31
+ }
32
+ function ownKeys(e, r) {
33
+ var t = Object.keys(e);
34
+ if (Object.getOwnPropertySymbols) {
35
+ var o = Object.getOwnPropertySymbols(e);
36
+ r && (o = o.filter(function (r) {
37
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
38
+ })), t.push.apply(t, o);
39
+ }
40
+ return t;
41
+ }
42
+ function _objectSpread2(e) {
43
+ for (var r = 1; r < arguments.length; r++) {
44
+ var t = null != arguments[r] ? arguments[r] : {};
45
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
46
+ _defineProperty(e, r, t[r]);
47
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
48
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
49
+ });
50
+ }
51
+ return e;
52
+ }
53
+ function _toPrimitive(t, r) {
54
+ if ("object" != typeof t || !t) return t;
55
+ var e = t[Symbol.toPrimitive];
56
+ if (void 0 !== e) {
57
+ var i = e.call(t, r || "default");
58
+ if ("object" != typeof i) return i;
59
+ throw new TypeError("@@toPrimitive must return a primitive value.");
60
+ }
61
+ return ("string" === r ? String : Number)(t);
62
+ }
63
+ function _toPropertyKey(t) {
64
+ var i = _toPrimitive(t, "string");
65
+ return "symbol" == typeof i ? i : i + "";
66
+ }
67
+ function _defineProperty(obj, key, value) {
68
+ key = _toPropertyKey(key);
69
+ if (key in obj) {
70
+ Object.defineProperty(obj, key, {
71
+ value: value,
72
+ enumerable: true,
73
+ configurable: true,
74
+ writable: true
75
+ });
76
+ } else {
77
+ obj[key] = value;
78
+ }
79
+ return obj;
80
+ }
81
+ function _slicedToArray(arr, i) {
82
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
83
+ }
84
+ function _toConsumableArray(arr) {
85
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
86
+ }
87
+ function _arrayWithoutHoles(arr) {
88
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
89
+ }
90
+ function _arrayWithHoles(arr) {
91
+ if (Array.isArray(arr)) return arr;
92
+ }
93
+ function _iterableToArray(iter) {
94
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
95
+ }
96
+ function _unsupportedIterableToArray(o, minLen) {
97
+ if (!o) return;
98
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
99
+ var n = Object.prototype.toString.call(o).slice(8, -1);
100
+ if (n === "Object" && o.constructor) n = o.constructor.name;
101
+ if (n === "Map" || n === "Set") return Array.from(o);
102
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
103
+ }
104
+ function _arrayLikeToArray(arr, len) {
105
+ if (len == null || len > arr.length) len = arr.length;
106
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
107
+ return arr2;
108
+ }
109
+ function _nonIterableSpread() {
110
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
+ }
112
+ function _nonIterableRest() {
113
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
114
+ }
115
+ function _createForOfIteratorHelper(o, allowArrayLike) {
116
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
117
+ if (!it) {
118
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
119
+ if (it) o = it;
120
+ var i = 0;
121
+ var F = function () {};
122
+ return {
123
+ s: F,
124
+ n: function () {
125
+ if (i >= o.length) return {
126
+ done: true
127
+ };
128
+ return {
129
+ done: false,
130
+ value: o[i++]
131
+ };
132
+ },
133
+ e: function (e) {
134
+ throw e;
135
+ },
136
+ f: F
137
+ };
138
+ }
139
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
140
+ }
141
+ var normalCompletion = true,
142
+ didErr = false,
143
+ err;
144
+ return {
145
+ s: function () {
146
+ it = it.call(o);
147
+ },
148
+ n: function () {
149
+ var step = it.next();
150
+ normalCompletion = step.done;
151
+ return step;
152
+ },
153
+ e: function (e) {
154
+ didErr = true;
155
+ err = e;
156
+ },
157
+ f: function () {
158
+ try {
159
+ if (!normalCompletion && it.return != null) it.return();
160
+ } finally {
161
+ if (didErr) throw err;
162
+ }
163
+ }
164
+ };
165
+ }
166
+
167
+ /**
168
+ * @name chunk
169
+ * Separate an array into smaller arrays of length `size`.
170
+ * If the array cannot be separated in equal size, the final sub-array will have the remaining elements.
171
+ * @param arr The array to chunk
172
+ * @param size The size of smaller arrays
173
+ */
174
+ function chunk(arr, size) {
175
+ if (!Number.isInteger(size) || size <= 0) {
176
+ throw new Error("Size must be an integer greater than zero.");
177
+ }
178
+ var result = [];
179
+ var _iterator = _createForOfIteratorHelper(arr.entries()),
180
+ _step;
181
+ try {
182
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
183
+ var _step$value = _slicedToArray(_step.value, 2),
184
+ index = _step$value[0],
185
+ item = _step$value[1];
186
+ if (index % size === 0) {
187
+ result.push([]);
188
+ }
189
+ result[result.length - 1].push(item);
190
+ }
191
+ } catch (err) {
192
+ _iterator.e(err);
193
+ } finally {
194
+ _iterator.f();
195
+ }
196
+ return result;
197
+ }
198
+
199
+ /**
200
+ * @name difference
201
+ * Returns the difference of two arrays.
202
+ * @param firstArr The array to get the difference from
203
+ * @param secondArr The elements to exclude from `firstArr`
204
+ */
205
+ function difference(firstArr, secondArr) {
206
+ return firstArr.filter(function (item) {
207
+ return !secondArr.includes(item);
208
+ });
209
+ }
210
+
211
+ /**
212
+ * @name differenceBy
213
+ * Returns the difference of two arrays. The identity of two elements is calculated after the elements are mapped with `mapper`.
214
+ * @param firstArr The array to get the difference from
215
+ * @param secondArr The elements to exclude from `firstArr`
216
+ * @param mapper The function to map the elements when calculating the difference
217
+ */
218
+ function differenceBy(firstArr, secondArr, mapper) {
219
+ var mappedSecondArr = secondArr.map(function (item) {
220
+ return mapper(item);
221
+ });
222
+ return firstArr.filter(function (item) {
223
+ return !mappedSecondArr.includes(mapper(item));
224
+ });
225
+ }
226
+
227
+ /**
228
+ * @name differenceWith
229
+ * Returns the difference of two arrays. The identity of two elements is calculated with the function `areItemsEqual`.
230
+ * @param firstArr The array to get the difference from
231
+ * @param secondArr The elements to exclude from `firstArr`
232
+ * @param areItemsEqual The function to determine whether two items are equal
233
+ */
234
+ function differenceWith(firstArr, secondArr, areItemsEqual) {
235
+ return firstArr.filter(function (firstItem) {
236
+ return secondArr.every(function (secondItem) {
237
+ return !areItemsEqual(firstItem, secondItem);
238
+ });
239
+ });
240
+ }
241
+
242
+ /**
243
+ * @name drop
244
+ * Drop some elements from an array from the beginning. This function returns a new array.
245
+ * @param arr The element to drop items from the beginning
246
+ * @param itemsCount The amount of elements to drop
247
+ */
248
+ function drop(arr, itemsCount) {
249
+ return arr.slice(itemsCount);
250
+ }
251
+
252
+ /**
253
+ * @name dropRight
254
+ * Drop some elements from an array from the end. This function returns a new array.
255
+ * @param arr The element to drop items from the end
256
+ * @param itemsCount The amount of elements to drop
257
+ */
258
+ function dropRight(arr, itemsCount) {
259
+ return arr.slice(0, -itemsCount);
260
+ }
261
+
262
+ /**
263
+ * @name dropWhile
264
+ * Drop some elements from an array from the beginning, until `predicate` returns false.
265
+ * @param arr The element to drop items from the beginning
266
+ * @param canContinueDropping The predicate to check if the function can continue dropping elements.
267
+ */
268
+ function dropWhile(arr, canContinueDropping) {
269
+ var dropEndIndex = arr.findIndex(function (item) {
270
+ return !canContinueDropping(item);
271
+ });
272
+ return arr.slice(dropEndIndex);
273
+ }
274
+
275
+ /**
276
+ * @name dropRightWhile
277
+ * Drop some elements from an array from the end, until `predicate` returns false.
278
+ * @param arr The element to drop items from the end
279
+ * @param canContinueDropping The predicate to check if the function can continue dropping elements.
280
+ */
281
+ function dropRightWhile(arr, canContinueDropping) {
282
+ var reversed = arr.slice().reverse();
283
+ var dropped = dropWhile(reversed, canContinueDropping);
284
+ return dropped.slice().reverse();
285
+ }
286
+
287
+ function groupBy() {
288
+ throw new Error('Not implemented');
289
+ }
290
+
291
+ /**
292
+ * @name intersection
293
+ * @description
294
+ * Returns the intersection of two arrays.
295
+ * @param firstArr The first array to get the intersection
296
+ * @param secondArr The second array to get the intersection
297
+ * @example
298
+ * intersection([1, 2], [1, 3]) === [1]
299
+ * intersection([1, 2, 3], [2, 3, 4]) === [2, 3]
300
+ */
301
+ function intersection(firstArr, secondArr) {
302
+ return firstArr.filter(function (item) {
303
+ return secondArr.includes(item);
304
+ });
305
+ }
306
+
307
+ /**
308
+ * @name intersectionBy
309
+ * @description
310
+ * Returns the intersection of two arrays. The identity of two elements is calculated after the elements are mapped with `mapper`.
311
+ * @param firstArr The first array to get the intersection
312
+ * @param secondArr The second array to get the intersection
313
+ * @param mapper The function to map the elements when calculating the intersection
314
+ * @example
315
+ * intersectionBy([1.2, 2.1], [1.4, 3.1], Math.floor) === [1.2]
316
+ * intersectionBy([{ foo: 1 }, { foo: 2 }], [{ foo: 1 }, { foo: 3 }], x => x.foo) === [{ foo: 1 }]
317
+ */
318
+ function intersectionBy(firstArr, secondArr, mapper) {
319
+ var mappedSecondArr = secondArr.map(function (x) {
320
+ return mapper(x);
321
+ });
322
+ return firstArr.filter(function (item) {
323
+ return mappedSecondArr.includes(mapper(item));
324
+ });
325
+ }
326
+
327
+ /**
328
+ * @name intersectionWith
329
+ * @description
330
+ * Returns the intersection of two arrays. The identity of two elements is compared with `areItemsEqual`.
331
+ * @param firstArr The first array to get the intersection
332
+ * @param secondArr The second array to get the intersection
333
+ * @param areItemsEqual The function to compare the identity of two elements
334
+ * @example
335
+ * intersectionWith([1.2, 2.1], [1.4, 3.1], (x, y) => Math.floor(x) === Math.floor(y)) === [1.2]
336
+ * intersectionWith([{ foo: 1 }, { foo: 2 }], [{ foo: 1 }, { foo: 3 }], (x, y) => x.foo === y.foo) === [{ foo: 1 }]
337
+ */
338
+ function intersectionWith(firstArr, secondArr, areItemsEqual) {
339
+ return firstArr.filter(function (firstItem) {
340
+ return secondArr.some(function (secondItem) {
341
+ return areItemsEqual(firstItem, secondItem);
342
+ });
343
+ });
344
+ }
345
+
346
+ /**
347
+ * @name partition
348
+ * @description
349
+ * Creates two arrays: the first array includes items for which isInTruthy returns true, and the second array includes items for which isInTruthy returns false.
350
+ * @param arr The array to split into two arrays
351
+ * @param isInTruthy The predicate to tell whether an item is included in the first array
352
+ */
353
+ function partition(arr, isInTruthy) {
354
+ var truthy = [];
355
+ var falsy = [];
356
+ var _iterator = _createForOfIteratorHelper(arr),
357
+ _step;
358
+ try {
359
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
360
+ var item = _step.value;
361
+ if (isInTruthy(item)) {
362
+ truthy.push(item);
363
+ } else {
364
+ falsy.push(item);
365
+ }
366
+ }
367
+ } catch (err) {
368
+ _iterator.e(err);
369
+ } finally {
370
+ _iterator.f();
371
+ }
372
+ return [truthy, falsy];
373
+ }
374
+
375
+ /**
376
+ * @name sample
377
+ * @description
378
+ * Returns a random element from an array.
379
+ * @param arr The element to get a random element
380
+ */
381
+ function sample(arr) {
382
+ var randomIndex = Math.floor(Math.random() * arr.length);
383
+ return arr[randomIndex];
384
+ }
385
+
386
+ /**
387
+ * @name shuffle
388
+ * @description
389
+ * Randomize the order of an array.
390
+ * @param arr The array to shuffle
391
+ */
392
+ function shuffle(arr) {
393
+ /**
394
+ * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
395
+ */
396
+ for (var i = arr.length - 1; i >= 1; i--) {
397
+ var j = Math.floor(Math.random() * i);
398
+ var _ref = [arr[j], arr[i]];
399
+ arr[i] = _ref[0];
400
+ arr[j] = _ref[1];
401
+ }
402
+ return arr;
403
+ }
404
+
405
+ /**
406
+ * Returns a new array containing the first `count` elements from the input array `arr`.
407
+ * If `count` is greater than the length of `arr`, the entire array is returned.
408
+ *
409
+ * @template T - Type of elements in the input array.
410
+ *
411
+ * @param {T[]} arr - The array to take elements from.
412
+ * @param {number} count - The number of elements to take.
413
+ * @returns {T[]} A new array containing the first `count` elements from `arr`.
414
+ *
415
+ * @example
416
+ * // Returns [1, 2, 3]
417
+ * take([1, 2, 3, 4, 5], 3);
418
+ *
419
+ * @example
420
+ * // Returns ['a', 'b']
421
+ * take(['a', 'b', 'c'], 2);
422
+ *
423
+ * @example
424
+ * // Returns [1, 2, 3]
425
+ * take([1, 2, 3], 5);
426
+ */
427
+ function take(arr, count) {
428
+ return arr.slice(0, count);
429
+ }
430
+
431
+ /**
432
+ * Returns a new array containing the last `count` elements from the input array `arr`.
433
+ * If `count` is greater than the length of `arr`, the entire array is returned.
434
+ *
435
+ * @template T - Type of elements in the input array.
436
+ *
437
+ * @param {T[]} arr - The array to take elements from.
438
+ * @param {number} count - The number of elements to take.
439
+ * @returns {T[]} A new array containing the last `count` elements from `arr`.
440
+ *
441
+ * @example
442
+ * // Returns [4, 5]
443
+ * takeRight([1, 2, 3, 4, 5], 2);
444
+ *
445
+ * @example
446
+ * // Returns ['b', 'c']
447
+ * takeRight(['a', 'b', 'c'], 2);
448
+ *
449
+ * @example
450
+ * // Returns [1, 2, 3]
451
+ * takeRight([1, 2, 3], 5);
452
+ */
453
+ function takeRight(arr, count) {
454
+ if (count === 0) {
455
+ return [];
456
+ }
457
+ return arr.slice(-count);
458
+ }
459
+
460
+ /**
461
+ * Takes elements from the end of the array while the predicate function returns `true`.
462
+ *
463
+ * @template T - Type of elements in the input array.
464
+ *
465
+ * @param {T[]} arr - The array to take elements from.
466
+ * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.
467
+ * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
468
+ *
469
+ * @example
470
+ * // Returns [3, 2, 1]
471
+ * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
472
+ *
473
+ * @example
474
+ * // Returns []
475
+ * takeRightWhile([1, 2, 3], n => n > 3);
476
+ */
477
+ function takeRightWhile(arr, shouldContinueTaking) {
478
+ for (var i = arr.length - 1; i >= 0; i--) {
479
+ if (!shouldContinueTaking(arr[i])) {
480
+ return arr.slice(i + 1);
481
+ }
482
+ }
483
+ return arr.slice();
484
+ }
485
+
486
+ /**
487
+ * Returns a new array containing the leading elements of the provided array
488
+ * that satisfy the provided predicate function. It stops taking elements as soon
489
+ * as an element does not satisfy the predicate.
490
+ *
491
+ * @template T - The type of elements in the array.
492
+ * @param {T[]} arr - The array to process.
493
+ * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.
494
+ * @returns {T[]} A new array containing the leading elements that satisfy the predicate.
495
+ *
496
+ * @example
497
+ * // Returns [1, 2]
498
+ * takeWhile([1, 2, 3, 4], x => x < 3);
499
+ *
500
+ * @example
501
+ * // Returns []
502
+ * takeWhile([1, 2, 3, 4], x => x > 3);
503
+ */
504
+ function takeWhile(arr, shouldContinueTaking) {
505
+ var result = [];
506
+ var _iterator = _createForOfIteratorHelper(arr),
507
+ _step;
508
+ try {
509
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
510
+ var item = _step.value;
511
+ if (!shouldContinueTaking(item)) {
512
+ break;
513
+ }
514
+ result.push(item);
515
+ }
516
+ } catch (err) {
517
+ _iterator.e(err);
518
+ } finally {
519
+ _iterator.f();
520
+ }
521
+ return result;
522
+ }
523
+
524
+ /**
525
+ * @name uniq
526
+ * @description
527
+ * `uniq` removes duplicated elements from the array given as an argument.
528
+ *
529
+ * It filters out elements with the same value, so duplicates of data types like Objects are not checked.
530
+ *
531
+ * @example
532
+ * ```ts
533
+ * uniq([1, 1, 2, 3, 5, 5, 7, 'foo', 'bar', 'bar']);
534
+ * // [1, 2, 3, 5, 7, 'foo', 'bar']
535
+ * ```
536
+ */
537
+ function uniq(arr) {
538
+ return Array.from(new Set(arr));
539
+ }
540
+
541
+ /**
542
+ * `union` function returns the union of the arrays passed as arguments.
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * union([2], [1, 2]);
547
+ * // [2, 1]
548
+ * ```
549
+ */
550
+ function union() {
551
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
552
+ args[_key] = arguments[_key];
553
+ }
554
+ return uniq(args.flat());
555
+ }
556
+
557
+ /**
558
+ * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
559
+ *
560
+ * @template T - Type of elements in the input arrays.
561
+ * @template U - Type of the values returned by the mapping function.
562
+ *
563
+ * @param {T[]} arr1 - The first array.
564
+ * @param {T[]} arr2 - The second array.
565
+ * @param {function(item: T): U} mapper - The function to map array elements to comparison values.
566
+ * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.
567
+ *
568
+ * @example
569
+ * // Custom mapping function for numbers (modulo comparison)
570
+ * const moduloMapper = (x) => x % 3;
571
+ * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);
572
+ * // Returns [1, 2, 3]
573
+ *
574
+ * @example
575
+ * // Custom mapping function for objects with an 'id' property
576
+ * const idMapper = (obj) => obj.id;
577
+ * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
578
+ * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
579
+ */
580
+ function unionBy(arr1, arr2, mapper) {
581
+ var map = new Map();
582
+ for (var _i = 0, _arr = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)); _i < _arr.length; _i++) {
583
+ var item = _arr[_i];
584
+ var key = mapper(item);
585
+ if (!map.has(key)) {
586
+ map.set(key, item);
587
+ }
588
+ }
589
+ return _toConsumableArray(map.values());
590
+ }
591
+
592
+ /**
593
+ * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
594
+ *
595
+ * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
600
+ * // [1, 2, 3, 5, 7]
601
+ * ```
602
+ */
603
+ function uniqWith(arr, areItemsEqual) {
604
+ var result = [];
605
+ var _iterator = _createForOfIteratorHelper(arr),
606
+ _step;
607
+ try {
608
+ var _loop = function _loop() {
609
+ var item = _step.value;
610
+ var isUniq = result.every(function (v) {
611
+ return !areItemsEqual(v, item);
612
+ });
613
+ if (isUniq) {
614
+ result.push(item);
615
+ }
616
+ };
617
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
618
+ _loop();
619
+ }
620
+ } catch (err) {
621
+ _iterator.e(err);
622
+ } finally {
623
+ _iterator.f();
624
+ }
625
+ return result;
626
+ }
627
+
628
+ /**
629
+ * `unionWith` function returns the union of multiple arrays passed as arguments. During this process, it removes any duplicated elements.
630
+ *
631
+ * @example
632
+ * ```ts
633
+ * unionWith(
634
+ * [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }],
635
+ * [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }],
636
+ * (x, y) => x === y
637
+ * );
638
+ * // [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
639
+ * ```
640
+ */
641
+ function unionWith(arr1, arr2, areItemsEqual) {
642
+ return uniqWith([].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)), areItemsEqual);
643
+ }
644
+
645
+ /**
646
+ * The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
647
+ *
648
+ * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
653
+ * // [1.2, 2.1, 3.3, 5.7, 7.19]
654
+ * ```
655
+ */
656
+ function uniqBy(arr, converter) {
657
+ return uniqWith(arr, function (item1, item2) {
658
+ return converter(item1) === converter(item2);
659
+ });
660
+ }
661
+
662
+ /**
663
+ * Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
664
+ * which are in either of the arrays, but not in their intersection.
665
+ *
666
+ * @template T - Type of elements in the input arrays.
667
+ *
668
+ * @param {T[]} arr1 - The first array.
669
+ * @param {T[]} arr2 - The second array.
670
+ * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
671
+ *
672
+ * @example
673
+ * // Returns [1, 2, 5, 6]
674
+ * xor([1, 2, 3, 4], [3, 4, 5, 6]);
675
+ *
676
+ * @example
677
+ * // Returns ['a', 'c']
678
+ * xor(['a', 'b'], ['b', 'c']);
679
+ */
680
+ function xor(arr1, arr2) {
681
+ return difference(union(arr1, arr2), intersection(arr1, arr2));
682
+ }
683
+
684
+ /**
685
+ * Computes the symmetric difference between two arrays using a custom mapping function.
686
+ * The symmetric difference is the set of elements which are in either of the arrays,
687
+ * but not in their intersection, determined by the result of the mapping function.
688
+ *
689
+ * @template T - Type of elements in the input arrays.
690
+ * @template U - Type of the values returned by the mapping function.
691
+ *
692
+ * @param {T[]} arr1 - The first array.
693
+ * @param {T[]} arr2 - The second array.
694
+ * @param {function(item: T): U} mapper - The function to map array elements to comparison values.
695
+ * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
696
+ *
697
+ * @example
698
+ * // Custom mapping function for objects with an 'id' property
699
+ * const idMapper = obj => obj.id;
700
+ * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
701
+ * // Returns [{ id: 1 }, { id: 3 }]
702
+ */
703
+ function xorBy(arr1, arr2, mapper) {
704
+ var union = unionBy(arr1, arr2, mapper);
705
+ var intersection = intersectionBy(arr1, arr2, mapper);
706
+ return differenceBy(union, intersection, mapper);
707
+ }
708
+
709
+ /**
710
+ * Computes the symmetric difference between two arrays using a custom equality function.
711
+ * The symmetric difference is the set of elements which are in either of the arrays,
712
+ * but not in their intersection.
713
+ *
714
+ * @template T - Type of elements in the input arrays.
715
+ *
716
+ * @param {T[]} arr1 - The first array.
717
+ * @param {T[]} arr2 - The second array.
718
+ * @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
719
+ * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
720
+ *
721
+ * @example
722
+ * // Custom equality function for objects with an 'id' property
723
+ * const areObjectsEqual = (a, b) => a.id === b.id;
724
+ * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
725
+ * // Returns [{ id: 1 }, { id: 3 }]
726
+ */
727
+ function xorWith(arr1, arr2, areElementsEqual) {
728
+ var union = unionWith(arr1, arr2, areElementsEqual);
729
+ var intersection = intersectionWith(arr1, arr2, areElementsEqual);
730
+ return differenceWith(union, intersection, areElementsEqual);
731
+ }
732
+
733
+ /**
734
+ * Merges multiple arrays element-wise. Returns an array where each element is an array containing
735
+ * elements from the input arrays at the corresponding index.
736
+ *
737
+ * @param {T[]} arr1 - The first array to be zipped.
738
+ * @param {T[]} arr2 - The second array to be zipped.
739
+ * @param {T[]} arr3 - The third array to be zipped.
740
+ * @param {T[]} arr4 - The fourth array to be zipped.
741
+ */
742
+
743
+ function zip() {
744
+ var result = [];
745
+ for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
746
+ arrs[_key] = arguments[_key];
747
+ }
748
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
749
+ return x.length;
750
+ })));
751
+ for (var i = 0; i < maxIndex; i++) {
752
+ var element = [];
753
+ var _iterator = _createForOfIteratorHelper(arrs),
754
+ _step;
755
+ try {
756
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
757
+ var arr = _step.value;
758
+ element.push(arr[i]);
759
+ }
760
+ } catch (err) {
761
+ _iterator.e(err);
762
+ } finally {
763
+ _iterator.f();
764
+ }
765
+ result.push(element);
766
+ }
767
+ return result;
768
+ }
769
+
770
+ /**
771
+ * Combines multiple arrays element-wise using a provided combining function.
772
+ * Returns an array where each element is the result of applying the combining function
773
+ * to the corresponding elements from the input arrays.
774
+ */
775
+
776
+ function zipWith(arr1) {
777
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
778
+ rest[_key - 1] = arguments[_key];
779
+ }
780
+ var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
781
+ var combine = rest[rest.length - 1];
782
+ var result = [];
783
+ var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
784
+ return arr.length;
785
+ })));
786
+ var _loop = function _loop(i) {
787
+ var elements = arrs.map(function (arr) {
788
+ return arr[i];
789
+ });
790
+ result.push(combine.apply(void 0, _toConsumableArray(elements)));
791
+ };
792
+ for (var i = 0; i < maxIndex; i++) {
793
+ _loop(i);
794
+ }
795
+ return result;
796
+ }
797
+
798
+ /**
799
+ * Creates a debounced function that delays invoking the provided function until after `waitMs` milliseconds
800
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
801
+ * method to cancel any pending execution.
802
+ *
803
+ * @param {() => void} func - The function to debounce.
804
+ * @param {number} waitMs - The number of milliseconds to delay.
805
+ * @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
806
+ *
807
+ * @example
808
+ * const debouncedFunction = debounce(() => {
809
+ * console.log('Function executed');
810
+ * }, 1000);
811
+ *
812
+ * // Will log 'Function executed' after 1 second if not called again in that time
813
+ * debouncedFunction();
814
+ *
815
+ * // Will not log anything as the previous call is canceled
816
+ * debouncedFunction.cancel();
817
+ */
818
+ function debounce(func, waitMs) {
819
+ var timeoutId = null;
820
+ var debounced = function debounced() {
821
+ if (timeoutId != null) {
822
+ clearTimeout(timeoutId);
823
+ }
824
+ timeoutId = setTimeout(function () {
825
+ func();
826
+ }, waitMs);
827
+ };
828
+ debounced.cancel = function () {
829
+ if (timeoutId != null) {
830
+ clearTimeout(timeoutId);
831
+ }
832
+ };
833
+ return debounced;
834
+ }
835
+
836
+ /**
837
+ * Creates a function that is restricted to invoking the provided function `func` once.
838
+ * Repeated calls to the function will return the value from the first invocation.
839
+ *
840
+ * @template F - The type of the function to be invoked once.
841
+ * @param {F} func - The function to restrict.
842
+ * @returns {F} A new function that invokes `func` once and caches the result.
843
+ *
844
+ * @example
845
+ * const initialize = once(() => {
846
+ * console.log('Initialized!');
847
+ * return true;
848
+ * });
849
+ *
850
+ * initialize(); // Logs: 'Initialized!' and returns true
851
+ * initialize(); // Returns true without logging
852
+ */
853
+ function once(func) {
854
+ var called = false;
855
+ var cache;
856
+ return function () {
857
+ if (called) {
858
+ return cache;
859
+ }
860
+ var result = func();
861
+ called = true;
862
+ cache = result;
863
+ return result;
864
+ };
865
+ }
866
+
867
+ /**
868
+ * Creates a throttled function that only invokes the provided function at most once
869
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
870
+ * within the wait time will not trigger the execution of the original function.
871
+ *
872
+ * @param {() => void} func - The function to throttle.
873
+ * @param {number} throttleMs - The number of milliseconds to throttle executions to.
874
+ * @returns {() => void} A new throttled function.
875
+ *
876
+ * @example
877
+ * const throttledFunction = throttle(() => {
878
+ * console.log('Function executed');
879
+ * }, 1000);
880
+ *
881
+ * // Will log 'Function executed' immediately
882
+ * throttledFunction();
883
+ *
884
+ * // Will not log anything as it is within the throttle time
885
+ * throttledFunction();
886
+ *
887
+ * // After 1 second
888
+ * setTimeout(() => {
889
+ * throttledFunction(); // Will log 'Function executed'
890
+ * }, 1000);
891
+ */
892
+ function throttle(func, throttleMs) {
893
+ var lastCallTime;
894
+ var throttledFunction = function throttledFunction() {
895
+ var now = Date.now();
896
+ if (lastCallTime == null || now - lastCallTime >= throttleMs) {
897
+ lastCallTime = now;
898
+ func();
899
+ }
900
+ };
901
+ return throttledFunction;
902
+ }
903
+
904
+ /**
905
+ * @name clamp
906
+ * @description Checks if `value` is within the bounds, if not return the closest bound (bound1: min, bound2: max)
907
+ * function clamp(value: number, bound1: number, bound2?: number): number
908
+ * @example
909
+ * clamp(3, 1) // 3
910
+ * clamp(3, 1, 5) // 3
911
+ * clamp(3, 5) // 5
912
+ * clamp(7, 3, 5) // 5
913
+ */
914
+ function clamp(value, bound1, bound2) {
915
+ if (bound2 == null) {
916
+ return Math.min(value, bound1);
917
+ }
918
+ return Math.min(Math.max(value, bound1), bound2);
919
+ }
920
+
921
+ /**
922
+ * @name round
923
+ * @description Rounds given number to given precision
924
+ * ```typescript
925
+ * function round(value: number, precision: number = 0): number
926
+ * ```
927
+ *
928
+ * @example
929
+ * round(1.2) === 1
930
+ * round(3.9) === 4
931
+ * round(8.5) === 9
932
+ */
933
+ function round(value) {
934
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
935
+ var multiplier = Math.pow(10, precision);
936
+ return Math.round(value * multiplier) / multiplier;
937
+ }
938
+
939
+ /**
940
+ * @name sum
941
+ * @description Return the sum of given values.
942
+ * ```typescript
943
+ * function sum(...nums: number[] | number[][]): number;
944
+ * ```
945
+ *
946
+ * @example
947
+ * sum(1, 2, 3) === 6
948
+ * sum(...[1, 2, 3]) === 6
949
+ * sum([1, 2, 3]) === 6
950
+ */
951
+ function sum() {
952
+ for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
953
+ nums[_key] = arguments[_key];
954
+ }
955
+ return nums.flat().reduce(function (acc, curr) {
956
+ return acc + curr;
957
+ }, 0);
958
+ }
959
+
960
+ /**
961
+ * @name omit
962
+ * Omit properties from an object.
963
+ * @param obj The object to omit properties from
964
+ * @param keys The keys to omit from an object
965
+ */
966
+ function omit(obj, keys) {
967
+ var result = _objectSpread2({}, obj);
968
+ var _iterator = _createForOfIteratorHelper(keys),
969
+ _step;
970
+ try {
971
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
972
+ var key = _step.value;
973
+ delete result[key];
974
+ }
975
+ } catch (err) {
976
+ _iterator.e(err);
977
+ } finally {
978
+ _iterator.f();
979
+ }
980
+ return result;
981
+ }
982
+
983
+ function omitBy() {
984
+ throw new Error('Not implemented');
985
+ }
986
+
987
+ /**
988
+ * @name pick
989
+ * Pick properties from an given object.
990
+ * @param obj The object to pick properties from
991
+ * @param keys The keys to pick from an object
992
+ */
993
+ function pick(obj, keys) {
994
+ var result = {};
995
+ var _iterator = _createForOfIteratorHelper(keys),
996
+ _step;
997
+ try {
998
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
999
+ var key = _step.value;
1000
+ result[key] = obj[key];
1001
+ }
1002
+ } catch (err) {
1003
+ _iterator.e(err);
1004
+ } finally {
1005
+ _iterator.f();
1006
+ }
1007
+ return result;
1008
+ }
1009
+
1010
+ function pickBy() {
1011
+ throw new Error('Not implemented');
1012
+ }
1013
+
1014
+ /**
1015
+ * @name isNil
1016
+ * Checks if the given value is null or undefined.
1017
+ * @param x The value to test if it is null or undefined
1018
+ */
1019
+ function isNil(x) {
1020
+ return x == null || x == undefined;
1021
+ }
1022
+
1023
+ /**
1024
+ * @name isNotNil
1025
+ * Checks if the given value is not null nor undefined.
1026
+ * The main use of this function is to used with TypeScript as a type predicate.
1027
+ * @param x The value to test if it is not null nor undefined
1028
+ * @example
1029
+ * // Here the type of `arr` is (number | undefined)[]
1030
+ * const arr = [1, undefined, 3];
1031
+ * // Here the type of `result` is number[]
1032
+ * const result = arr.filter(isNotNil);
1033
+ */
1034
+ function isNotNil(x) {
1035
+ return x != null && x != undefined;
1036
+ }
1037
+
1038
+ /**
1039
+ * @name isNull
1040
+ * Checks if the given value is null.
1041
+ * @param x The value to test if it is null
1042
+ */
1043
+ function isNull(x) {
1044
+ return x === null;
1045
+ }
1046
+
1047
+ /**
1048
+ * @name isUndefined
1049
+ * Checks if the given value is undefined.
1050
+ * @param x The value to test if it is undefined
1051
+ */
1052
+ function isUndefined(x) {
1053
+ return x === undefined;
1054
+ }
1055
+
1056
+ /**
1057
+ * @name delay
1058
+ * Pause the execution of a function for given milliseconds.
1059
+ * @param ms The amount of time to delay the function.
1060
+ */
1061
+ function delay(ms) {
1062
+ return new Promise(function (resolve) {
1063
+ setTimeout(resolve, ms);
1064
+ });
1065
+ }
1066
+
1067
+ exports.chunk = chunk;
1068
+ exports.clamp = clamp;
1069
+ exports.debounce = debounce;
1070
+ exports.delay = delay;
1071
+ exports.difference = difference;
1072
+ exports.differenceBy = differenceBy;
1073
+ exports.differenceWith = differenceWith;
1074
+ exports.drop = drop;
1075
+ exports.dropRight = dropRight;
1076
+ exports.dropRightWhile = dropRightWhile;
1077
+ exports.dropWhile = dropWhile;
1078
+ exports.groupBy = groupBy;
1079
+ exports.intersection = intersection;
1080
+ exports.intersectionBy = intersectionBy;
1081
+ exports.intersectionWith = intersectionWith;
1082
+ exports.isNil = isNil;
1083
+ exports.isNotNil = isNotNil;
1084
+ exports.isNull = isNull;
1085
+ exports.isUndefined = isUndefined;
1086
+ exports.omit = omit;
1087
+ exports.omitBy = omitBy;
1088
+ exports.once = once;
1089
+ exports.partition = partition;
1090
+ exports.pick = pick;
1091
+ exports.pickBy = pickBy;
1092
+ exports.round = round;
1093
+ exports.sample = sample;
1094
+ exports.shuffle = shuffle;
1095
+ exports.sum = sum;
1096
+ exports.take = take;
1097
+ exports.takeRight = takeRight;
1098
+ exports.takeRightWhile = takeRightWhile;
1099
+ exports.takeWhile = takeWhile;
1100
+ exports.throttle = throttle;
1101
+ exports.union = union;
1102
+ exports.unionBy = unionBy;
1103
+ exports.unionWith = unionWith;
1104
+ exports.uniq = uniq;
1105
+ exports.uniqBy = uniqBy;
1106
+ exports.uniqWith = uniqWith;
1107
+ exports.xor = xor;
1108
+ exports.xorBy = xorBy;
1109
+ exports.xorWith = xorWith;
1110
+ exports.zip = zip;
1111
+ exports.zipWith = zipWith;