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
@@ -2,32 +2,39 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const initial = require('../_chunk/initial-Ci2bn_.js');
6
- const promise_index = require('../_chunk/index-CoqN5B.js');
7
- const function_index = require('../function/index.js');
5
+ const zipWith = require('../_chunk/zipWith-CYaH1Y.js');
6
+ const promise_index = require('../_chunk/index-BGZDR9.js');
7
+ const rest$1 = require('../_chunk/rest-CXt9w3.js');
8
8
  const math_index = require('../math/index.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
- const toMerged = require('../_chunk/toMerged-BGwYW5.js');
11
- const isFunction = require('../_chunk/isFunction-aCEz9d.js');
12
- const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
10
+ const toMerged = require('../_chunk/toMerged-DN1PPP.js');
11
+ const isWeakSet$1 = require('../_chunk/isWeakSet-CogETi.js');
12
+ const isTypedArray$1 = require('../_chunk/isTypedArray-Dsrnb1.js');
13
13
  const string_index = require('../string/index.js');
14
14
 
15
+ function castArray(value) {
16
+ if (arguments.length === 0) {
17
+ return [];
18
+ }
19
+ return Array.isArray(value) ? value : [value];
20
+ }
21
+
15
22
  function chunk(arr, size = 1) {
16
23
  size = Math.max(Math.floor(size), 0);
17
24
  if (size === 0) {
18
25
  return [];
19
26
  }
20
- return initial.chunk(arr, size);
27
+ return zipWith.chunk(arr, size);
21
28
  }
22
29
 
23
30
  function concat(...values) {
24
- return initial.flatten(values);
31
+ return zipWith.flatten(values);
25
32
  }
26
33
 
27
34
  function difference(arr, ...values) {
28
35
  const arr1 = arr;
29
- const arr2 = initial.flatten(values);
30
- return initial.difference(arr1, arr2);
36
+ const arr2 = zipWith.flatten(values);
37
+ return zipWith.difference(arr1, arr2);
31
38
  }
32
39
 
33
40
  function fill(array, value, start = 0, end = array.length) {
@@ -39,7 +46,7 @@ function fill(array, value, start = 0, end = array.length) {
39
46
  if (!end) {
40
47
  end = 0;
41
48
  }
42
- return initial.fill(array, value, start, end);
49
+ return zipWith.fill(array, value, start, end);
43
50
  }
44
51
 
45
52
  const IS_PLAIN = /^\w*$/;
@@ -250,14 +257,14 @@ function cloneDeep(obj) {
250
257
  return toMerged.cloneDeep(obj);
251
258
  }
252
259
  switch (Object.prototype.toString.call(obj)) {
253
- case isFunction.numberTag:
254
- case isFunction.stringTag:
255
- case isFunction.booleanTag: {
260
+ case isWeakSet$1.numberTag:
261
+ case isWeakSet$1.stringTag:
262
+ case isWeakSet$1.booleanTag: {
256
263
  const result = new obj.constructor(obj?.valueOf());
257
264
  toMerged.copyProperties(result, obj);
258
265
  return result;
259
266
  }
260
- case isFunction.argumentsTag: {
267
+ case isWeakSet$1.argumentsTag: {
261
268
  const result = {};
262
269
  toMerged.copyProperties(result, obj);
263
270
  result.length = obj.length;
@@ -286,7 +293,7 @@ function isIndex(value) {
286
293
  }
287
294
 
288
295
  function isArguments(value) {
289
- return value !== null && typeof value === 'object' && isFunction.getTag(value) === '[object Arguments]';
296
+ return value !== null && typeof value === 'object' && isWeakSet$1.getTag(value) === '[object Arguments]';
290
297
  }
291
298
 
292
299
  function has(object, path) {
@@ -390,6 +397,34 @@ function findIndex(source, doesMatch) {
390
397
  }
391
398
  }
392
399
 
400
+ function findLastIndex(source, doesMatch, fromIndex = source.length - 1) {
401
+ if (fromIndex < 0) {
402
+ fromIndex = Math.max(source.length + fromIndex, 0);
403
+ }
404
+ else {
405
+ fromIndex = Math.min(fromIndex, source.length - 1);
406
+ }
407
+ source = source.slice(0, fromIndex + 1);
408
+ switch (typeof doesMatch) {
409
+ case 'function': {
410
+ return source.findLastIndex(doesMatch);
411
+ }
412
+ case 'object': {
413
+ if (Array.isArray(doesMatch) && doesMatch.length === 2) {
414
+ const key = doesMatch[0];
415
+ const value = doesMatch[1];
416
+ return source.findLastIndex(matchesProperty(key, value));
417
+ }
418
+ else {
419
+ return source.findLastIndex(matches(doesMatch));
420
+ }
421
+ }
422
+ case 'string': {
423
+ return source.findLastIndex(property(doesMatch));
424
+ }
425
+ }
426
+ }
427
+
393
428
  function flatten(value, depth = 1) {
394
429
  const result = [];
395
430
  const flooredDepth = Math.floor(depth);
@@ -426,12 +461,60 @@ function flattenDepth(value, depth = 1) {
426
461
  return flatten(value, depth);
427
462
  }
428
463
 
429
- const compareValues = (a, b, order) => {
430
- if ((a != null && b == null) || a < b) {
431
- return order === 'desc' ? 1 : -1;
464
+ function indexOf(array, searchElement, fromIndex) {
465
+ if (array == null) {
466
+ return -1;
467
+ }
468
+ if (Number.isNaN(searchElement)) {
469
+ fromIndex = fromIndex ?? 0;
470
+ if (fromIndex < 0) {
471
+ fromIndex = Math.max(0, array.length + fromIndex);
472
+ }
473
+ for (let i = fromIndex; i < array.length; i++) {
474
+ if (Number.isNaN(array[i])) {
475
+ return i;
476
+ }
477
+ }
478
+ return -1;
479
+ }
480
+ return array.indexOf(searchElement, fromIndex);
481
+ }
482
+
483
+ function join(array, separator = ',') {
484
+ return array.join(separator);
485
+ }
486
+
487
+ function getPriority(a) {
488
+ if (typeof a === 'symbol') {
489
+ return 1;
490
+ }
491
+ if (a === null) {
492
+ return 2;
493
+ }
494
+ if (a === undefined) {
495
+ return 3;
432
496
  }
433
- if ((a == null && b != null) || a > b) {
434
- return order === 'desc' ? -1 : 1;
497
+ if (a !== a) {
498
+ return 4;
499
+ }
500
+ return 0;
501
+ }
502
+ const compareValues = (a, b, order) => {
503
+ if (a !== b) {
504
+ if (typeof a === 'string' && typeof b === 'string') {
505
+ return order === 'desc' ? b.localeCompare(a) : a.localeCompare(b);
506
+ }
507
+ const aPriority = getPriority(a);
508
+ const bPriority = getPriority(b);
509
+ if (aPriority === bPriority && aPriority === 0) {
510
+ if (a < b) {
511
+ return order === 'desc' ? 1 : -1;
512
+ }
513
+ if (a > b) {
514
+ return order === 'desc' ? -1 : 1;
515
+ }
516
+ }
517
+ return order === 'desc' ? bPriority - aPriority : aPriority - bPriority;
435
518
  }
436
519
  return 0;
437
520
  };
@@ -450,68 +533,80 @@ function isKey(value, object) {
450
533
  }
451
534
 
452
535
  function orderBy(collection, criteria, orders) {
453
- if (collection == null) {
536
+ if (collection == null || typeof collection === 'number') {
454
537
  return [];
455
538
  }
456
- if (!Array.isArray(collection) && typeof collection === 'object') {
539
+ if (typeof collection === 'object' && !Array.isArray(collection)) {
457
540
  collection = Object.values(collection);
458
541
  }
459
542
  if (!Array.isArray(criteria)) {
460
- criteria = criteria == null ? [] : [criteria];
543
+ criteria = criteria == null ? [null] : [criteria];
461
544
  }
462
545
  if (!Array.isArray(orders)) {
463
546
  orders = orders == null ? [] : [orders];
464
547
  }
548
+ orders = orders.map(order => String(order));
465
549
  const getValueByNestedPath = (object, path) => {
466
550
  let target = object;
467
- for (let i = 0; i < path.length && target != null; i++) {
551
+ for (let i = 0; i < path.length && target != null; ++i) {
468
552
  target = target[path[i]];
469
553
  }
470
554
  return target;
471
555
  };
472
556
  const getValueByCriterion = (criterion, object) => {
473
- if (object == null) {
557
+ if (object == null || criterion == null) {
474
558
  return object;
475
559
  }
560
+ if (typeof criterion === 'object' && 'key' in criterion) {
561
+ if (Object.hasOwn(object, criterion.key)) {
562
+ return object[criterion.key];
563
+ }
564
+ return getValueByNestedPath(object, criterion.path);
565
+ }
476
566
  if (typeof criterion === 'function') {
477
567
  return criterion(object);
478
568
  }
479
569
  if (Array.isArray(criterion)) {
480
570
  return getValueByNestedPath(object, criterion);
481
571
  }
482
- if (typeof criterion !== 'object') {
572
+ if (typeof object === 'object') {
483
573
  return object[criterion];
484
574
  }
485
- if (Object.hasOwn(object, criterion.key)) {
486
- return object[criterion.key];
487
- }
488
- return getValueByNestedPath(object, criterion.path);
575
+ return object;
489
576
  };
490
577
  const preparedCriteria = criteria.map(criterion => {
491
578
  if (Array.isArray(criterion) && criterion.length === 1) {
492
579
  criterion = criterion[0];
493
580
  }
494
- if (typeof criterion === 'function' || Array.isArray(criterion) || isKey(criterion)) {
581
+ if (criterion == null || typeof criterion === 'function' || Array.isArray(criterion) || isKey(criterion)) {
495
582
  return criterion;
496
583
  }
497
584
  return { key: criterion, path: toPath(criterion) };
498
585
  });
499
- return collection.slice().sort((a, b) => {
500
- for (let i = 0; i < criteria.length; i++) {
501
- const order = String(orders[i]);
502
- const valueA = getValueByCriterion(preparedCriteria[i], a);
503
- const valueB = getValueByCriterion(preparedCriteria[i], b);
504
- const comparedResult = compareValues(valueA, valueB, order);
586
+ const preparedCollection = collection.map(item => ({
587
+ original: item,
588
+ criteria: preparedCriteria.map(criterion => getValueByCriterion(criterion, item)),
589
+ }));
590
+ return preparedCollection
591
+ .slice()
592
+ .sort((a, b) => {
593
+ for (let i = 0; i < preparedCriteria.length; i++) {
594
+ const comparedResult = compareValues(a.criteria[i], b.criteria[i], orders[i]);
505
595
  if (comparedResult !== 0) {
506
596
  return comparedResult;
507
597
  }
508
598
  }
509
599
  return 0;
510
- });
600
+ })
601
+ .map(item => item.original);
602
+ }
603
+
604
+ function sortBy(collection, criteria) {
605
+ return orderBy(collection, criteria, ['asc']);
511
606
  }
512
607
 
513
608
  function size(target) {
514
- if (isFunction.isNil(target)) {
609
+ if (isWeakSet$1.isNil(target)) {
515
610
  return 0;
516
611
  }
517
612
  if (target instanceof Map || target instanceof Set) {
@@ -520,6 +615,40 @@ function size(target) {
520
615
  return Object.keys(target).length;
521
616
  }
522
617
 
618
+ function identity(x) {
619
+ return x;
620
+ }
621
+
622
+ function some(arr, predicate, guard) {
623
+ if (guard != null) {
624
+ predicate = undefined;
625
+ }
626
+ if (!predicate) {
627
+ predicate = identity;
628
+ }
629
+ if (!Array.isArray(arr)) {
630
+ return false;
631
+ }
632
+ switch (typeof predicate) {
633
+ case 'function': {
634
+ return arr.some(predicate);
635
+ }
636
+ case 'object': {
637
+ if (Array.isArray(predicate) && predicate.length === 2) {
638
+ const key = predicate[0];
639
+ const value = predicate[1];
640
+ return arr.some(matchesProperty(key, value));
641
+ }
642
+ else {
643
+ return arr.some(matches(predicate));
644
+ }
645
+ }
646
+ case 'string': {
647
+ return arr.some(property(predicate));
648
+ }
649
+ }
650
+ }
651
+
523
652
  function set(obj, path, value) {
524
653
  const resolvedPath = Array.isArray(path) ? path : typeof path === 'string' ? toPath(path) : [path];
525
654
  let current = obj;
@@ -538,7 +667,7 @@ function set(obj, path, value) {
538
667
 
539
668
  function zipObjectDeep(keys, values) {
540
669
  const result = {};
541
- const zipped = initial.zip(keys, values);
670
+ const zipped = zipWith.zip(keys, values);
542
671
  for (let i = 0; i < zipped.length; i++) {
543
672
  const [key, value] = zipped[i];
544
673
  if (key != null) {
@@ -548,25 +677,6 @@ function zipObjectDeep(keys, values) {
548
677
  return result;
549
678
  }
550
679
 
551
- function indexOf(array, searchElement, fromIndex) {
552
- if (array == null) {
553
- return -1;
554
- }
555
- if (Number.isNaN(searchElement)) {
556
- fromIndex = fromIndex ?? 0;
557
- if (fromIndex < 0) {
558
- fromIndex = Math.max(0, array.length + fromIndex);
559
- }
560
- for (let i = fromIndex; i < array.length; i++) {
561
- if (Number.isNaN(array[i])) {
562
- return i;
563
- }
564
- }
565
- return -1;
566
- }
567
- return array.indexOf(searchElement, fromIndex);
568
- }
569
-
570
680
  function ary(func, n = func.length, guard) {
571
681
  if (guard) {
572
682
  n = func.length;
@@ -574,7 +684,7 @@ function ary(func, n = func.length, guard) {
574
684
  if (Number.isNaN(n) || n < 0) {
575
685
  n = 0;
576
686
  }
577
- return function_index.ary(func, n);
687
+ return rest$1.ary(func, n);
578
688
  }
579
689
 
580
690
  function bind(func, thisObj, ...partialArgs) {
@@ -603,16 +713,73 @@ function bind(func, thisObj, ...partialArgs) {
603
713
  const bindPlaceholder = Symbol('bind.placeholder');
604
714
  bind.placeholder = bindPlaceholder;
605
715
 
716
+ function bindKey(object, key, ...partialArgs) {
717
+ const bound = function (...providedArgs) {
718
+ const args = [];
719
+ let startIndex = 0;
720
+ for (let i = 0; i < partialArgs.length; i++) {
721
+ const arg = partialArgs[i];
722
+ if (arg === bindKey.placeholder) {
723
+ args.push(providedArgs[startIndex++]);
724
+ }
725
+ else {
726
+ args.push(arg);
727
+ }
728
+ }
729
+ for (let i = startIndex; i < providedArgs.length; i++) {
730
+ args.push(providedArgs[i]);
731
+ }
732
+ if (this instanceof bound) {
733
+ return new object[key](...args);
734
+ }
735
+ return object[key].apply(object, args);
736
+ };
737
+ return bound;
738
+ }
739
+ const bindKeyPlaceholder = Symbol('bindKey.placeholder');
740
+ bindKey.placeholder = bindKeyPlaceholder;
741
+
606
742
  function rest(func, start = func.length - 1) {
607
743
  start = Number.parseInt(start, 10);
608
744
  if (Number.isNaN(start) || start < 0) {
609
745
  start = func.length - 1;
610
746
  }
611
- return function_index.rest(func, start);
747
+ return rest$1.rest(func, start);
612
748
  }
613
749
 
614
- function identity(x) {
615
- return x;
750
+ function spread(func, argsIndex = 0) {
751
+ argsIndex = Number.parseInt(argsIndex, 10);
752
+ if (Number.isNaN(argsIndex) || argsIndex < 0) {
753
+ argsIndex = 0;
754
+ }
755
+ return function (...args) {
756
+ const array = args[argsIndex];
757
+ const params = args.slice(0, argsIndex);
758
+ if (array) {
759
+ params.push(...array);
760
+ }
761
+ return func.apply(this, params);
762
+ };
763
+ }
764
+
765
+ function attempt(func, ...args) {
766
+ try {
767
+ return func(...args);
768
+ }
769
+ catch (e) {
770
+ return e instanceof Error ? e : new Error(e);
771
+ }
772
+ }
773
+
774
+ function rearg(func, ...indices) {
775
+ const flattenIndices = flatten(indices);
776
+ return function (...args) {
777
+ const reorderedArgs = flattenIndices.map(i => args[i]).slice(0, args.length);
778
+ for (let i = reorderedArgs.length; i < args.length; i++) {
779
+ reorderedArgs.push(args[i]);
780
+ }
781
+ return func.apply(this, reorderedArgs);
782
+ };
616
783
  }
617
784
 
618
785
  function mapKeys(object, getNewKey) {
@@ -742,48 +909,107 @@ function mergeWithDeep(target, source, merge, stack) {
742
909
  }
743
910
 
744
911
  function merge(object, ...sources) {
745
- return mergeWith(object, ...sources, function_index.noop);
912
+ return mergeWith(object, ...sources, rest$1.noop);
913
+ }
914
+
915
+ function isArrayLike(value) {
916
+ return value != null && typeof value !== 'function' && isWeakSet$1.isLength(value.length);
917
+ }
918
+
919
+ function fromPairs(pairs) {
920
+ if (!isArrayLike(pairs) && !(pairs instanceof Map)) {
921
+ return {};
922
+ }
923
+ const result = {};
924
+ for (const [key, value] of pairs) {
925
+ result[key] = value;
926
+ }
927
+ return result;
746
928
  }
747
929
 
748
930
  function isArray(value) {
749
931
  return Array.isArray(value);
750
932
  }
751
933
 
752
- function isArrayLike(value) {
753
- return value != null && typeof value !== 'function' && isFunction.isLength(value.length);
934
+ function isObject(value) {
935
+ return value !== null && (typeof value === 'object' || typeof value === 'function');
754
936
  }
755
937
 
756
938
  function isBoolean(x) {
757
939
  if (x === true || x === false) {
758
940
  return true;
759
941
  }
760
- if (typeof x === 'object' && x != null && isFunction.getTag(x) === '[object Boolean]') {
942
+ if (typeof x === 'object' && x != null && isWeakSet$1.getTag(x) === '[object Boolean]') {
761
943
  return true;
762
944
  }
763
945
  return false;
764
946
  }
765
947
 
766
948
  function isRegExp(value) {
767
- return isFunction.getTag(value) === '[object RegExp]';
949
+ return isWeakSet$1.getTag(value) === '[object RegExp]';
768
950
  }
769
951
 
770
952
  function isString(value) {
771
953
  if (typeof value === 'string') {
772
954
  return true;
773
955
  }
774
- if (typeof value === 'object' && value != null && isFunction.getTag(value) === '[object String]') {
956
+ if (typeof value === 'object' && value != null && isWeakSet$1.getTag(value) === '[object String]') {
775
957
  return true;
776
958
  }
777
959
  return false;
778
960
  }
779
961
 
780
- const startsWith = (str, target, position = 0) => {
962
+ function isWeakMap(value) {
963
+ return isWeakSet$1.isWeakMap(value);
964
+ }
965
+
966
+ function isWeakSet(value) {
967
+ return isWeakSet$1.isWeakSet(value);
968
+ }
969
+
970
+ function conformsTo(target, source) {
971
+ if (source == null) {
972
+ return true;
973
+ }
974
+ if (target == null) {
975
+ return Object.keys(source).length === 0;
976
+ }
977
+ for (const key of Object.keys(source)) {
978
+ const predicate = source[key];
979
+ const value = target[key];
980
+ if ((value === undefined && !(key in target)) || !predicate(value)) {
981
+ return false;
982
+ }
983
+ }
984
+ return true;
985
+ }
986
+
987
+ function conforms(source) {
988
+ source = toMerged.cloneDeep(source);
989
+ return function (object) {
990
+ return conformsTo(object, source);
991
+ };
992
+ }
993
+
994
+ function normalizeForCase(str) {
995
+ if (typeof str === 'object') {
996
+ str = str.toString();
997
+ }
998
+ str = str.replace(/['\u2019]/g, '');
999
+ return str;
1000
+ }
1001
+
1002
+ function camelCase(str) {
1003
+ return string_index.camelCase(normalizeForCase(str));
1004
+ }
1005
+
1006
+ function startsWith(str, target, position = 0) {
781
1007
  return str.startsWith(target, position);
782
- };
1008
+ }
783
1009
 
784
- const endsWith = (str, target, position = str.length) => {
1010
+ function endsWith(str, target, position = str.length) {
785
1011
  return str.endsWith(target, position);
786
- };
1012
+ }
787
1013
 
788
1014
  function padStart(str, length = 0, chars = ' ') {
789
1015
  return str.padStart(length, chars);
@@ -793,6 +1019,10 @@ function padEnd(str, length = 0, chars = ' ') {
793
1019
  return str.padEnd(length, chars);
794
1020
  }
795
1021
 
1022
+ function repeat(str, n) {
1023
+ return str.repeat(n);
1024
+ }
1025
+
796
1026
  function max(items = []) {
797
1027
  let maxElement = items[0];
798
1028
  let max = undefined;
@@ -817,72 +1047,79 @@ function min(items = []) {
817
1047
  return minElement;
818
1048
  }
819
1049
 
820
- exports.at = initial.at;
821
- exports.compact = initial.compact;
822
- exports.countBy = initial.countBy;
823
- exports.differenceBy = initial.differenceBy;
824
- exports.differenceWith = initial.differenceWith;
825
- exports.drop = initial.drop;
826
- exports.dropRight = initial.dropRight;
827
- exports.dropRightWhile = initial.dropRightWhile;
828
- exports.dropWhile = initial.dropWhile;
829
- exports.first = initial.head;
830
- exports.flatMap = initial.flatMap;
831
- exports.forEachRight = initial.forEachRight;
832
- exports.groupBy = initial.groupBy;
833
- exports.head = initial.head;
834
- exports.initial = initial.initial;
835
- exports.intersection = initial.intersection;
836
- exports.intersectionBy = initial.intersectionBy;
837
- exports.intersectionWith = initial.intersectionWith;
838
- exports.isSubset = initial.isSubset;
839
- exports.keyBy = initial.keyBy;
840
- exports.last = initial.last;
841
- exports.maxBy = initial.maxBy;
842
- exports.minBy = initial.minBy;
843
- exports.partition = initial.partition;
844
- exports.pullAt = initial.pullAt;
845
- exports.sample = initial.sample;
846
- exports.sampleSize = initial.sampleSize;
847
- exports.shuffle = initial.shuffle;
848
- exports.sortBy = initial.sortBy;
849
- exports.tail = initial.tail;
850
- exports.take = initial.take;
851
- exports.takeRight = initial.takeRight;
852
- exports.takeRightWhile = initial.takeRightWhile;
853
- exports.takeWhile = initial.takeWhile;
854
- exports.toFilled = initial.toFilled;
855
- exports.union = initial.union;
856
- exports.unionBy = initial.unionBy;
857
- exports.unionWith = initial.unionWith;
858
- exports.uniq = initial.uniq;
859
- exports.uniqBy = initial.uniqBy;
860
- exports.uniqWith = initial.uniqWith;
861
- exports.unzip = initial.unzip;
862
- exports.unzipWith = initial.unzipWith;
863
- exports.without = initial.without;
864
- exports.xor = initial.xor;
865
- exports.xorBy = initial.xorBy;
866
- exports.xorWith = initial.xorWith;
867
- exports.zip = initial.zip;
868
- exports.zipObject = initial.zipObject;
869
- exports.zipWith = initial.zipWith;
1050
+ function parseInt(string, radix = 0, guard) {
1051
+ if (guard) {
1052
+ radix = 0;
1053
+ }
1054
+ return Number.parseInt(string, radix);
1055
+ }
1056
+
1057
+ exports.at = zipWith.at;
1058
+ exports.compact = zipWith.compact;
1059
+ exports.countBy = zipWith.countBy;
1060
+ exports.differenceBy = zipWith.differenceBy;
1061
+ exports.differenceWith = zipWith.differenceWith;
1062
+ exports.drop = zipWith.drop;
1063
+ exports.dropRight = zipWith.dropRight;
1064
+ exports.dropRightWhile = zipWith.dropRightWhile;
1065
+ exports.dropWhile = zipWith.dropWhile;
1066
+ exports.first = zipWith.head;
1067
+ exports.flatMap = zipWith.flatMap;
1068
+ exports.flatMapDeep = zipWith.flatMapDeep;
1069
+ exports.forEachRight = zipWith.forEachRight;
1070
+ exports.groupBy = zipWith.groupBy;
1071
+ exports.head = zipWith.head;
1072
+ exports.initial = zipWith.initial;
1073
+ exports.intersection = zipWith.intersection;
1074
+ exports.intersectionBy = zipWith.intersectionBy;
1075
+ exports.intersectionWith = zipWith.intersectionWith;
1076
+ exports.isSubset = zipWith.isSubset;
1077
+ exports.keyBy = zipWith.keyBy;
1078
+ exports.last = zipWith.last;
1079
+ exports.maxBy = zipWith.maxBy;
1080
+ exports.minBy = zipWith.minBy;
1081
+ exports.partition = zipWith.partition;
1082
+ exports.pullAt = zipWith.pullAt;
1083
+ exports.sample = zipWith.sample;
1084
+ exports.sampleSize = zipWith.sampleSize;
1085
+ exports.shuffle = zipWith.shuffle;
1086
+ exports.tail = zipWith.tail;
1087
+ exports.take = zipWith.take;
1088
+ exports.takeRight = zipWith.takeRight;
1089
+ exports.takeRightWhile = zipWith.takeRightWhile;
1090
+ exports.takeWhile = zipWith.takeWhile;
1091
+ exports.toFilled = zipWith.toFilled;
1092
+ exports.union = zipWith.union;
1093
+ exports.unionBy = zipWith.unionBy;
1094
+ exports.unionWith = zipWith.unionWith;
1095
+ exports.uniq = zipWith.uniq;
1096
+ exports.uniqBy = zipWith.uniqBy;
1097
+ exports.uniqWith = zipWith.uniqWith;
1098
+ exports.unzip = zipWith.unzip;
1099
+ exports.unzipWith = zipWith.unzipWith;
1100
+ exports.without = zipWith.without;
1101
+ exports.xor = zipWith.xor;
1102
+ exports.xorBy = zipWith.xorBy;
1103
+ exports.xorWith = zipWith.xorWith;
1104
+ exports.zip = zipWith.zip;
1105
+ exports.zipObject = zipWith.zipObject;
1106
+ exports.zipWith = zipWith.zipWith;
870
1107
  exports.AbortError = promise_index.AbortError;
871
1108
  exports.TimeoutError = promise_index.TimeoutError;
872
1109
  exports.delay = promise_index.delay;
873
1110
  exports.timeout = promise_index.timeout;
874
1111
  exports.withTimeout = promise_index.withTimeout;
875
- exports.after = function_index.after;
876
- exports.before = function_index.before;
877
- exports.debounce = function_index.debounce;
878
- exports.memoize = function_index.memoize;
879
- exports.negate = function_index.negate;
880
- exports.noop = function_index.noop;
881
- exports.once = function_index.once;
882
- exports.partial = function_index.partial;
883
- exports.partialRight = function_index.partialRight;
884
- exports.throttle = function_index.throttle;
885
- exports.unary = function_index.unary;
1112
+ exports.after = rest$1.after;
1113
+ exports.before = rest$1.before;
1114
+ exports.debounce = rest$1.debounce;
1115
+ exports.memoize = rest$1.memoize;
1116
+ exports.negate = rest$1.negate;
1117
+ exports.noop = rest$1.noop;
1118
+ exports.once = rest$1.once;
1119
+ exports.partial = rest$1.partial;
1120
+ exports.partialRight = rest$1.partialRight;
1121
+ exports.throttle = rest$1.throttle;
1122
+ exports.unary = rest$1.unary;
886
1123
  exports.clamp = math_index.clamp;
887
1124
  exports.inRange = math_index.inRange;
888
1125
  exports.mean = math_index.mean;
@@ -903,36 +1140,47 @@ exports.omitBy = toMerged.omitBy;
903
1140
  exports.pick = toMerged.pick;
904
1141
  exports.pickBy = toMerged.pickBy;
905
1142
  exports.toMerged = toMerged.toMerged;
906
- exports.isEqual = isFunction.isEqual;
907
- exports.isFunction = isFunction.isFunction;
908
- exports.isLength = isFunction.isLength;
909
- exports.isNil = isFunction.isNil;
910
- exports.isNotNil = isFunction.isNotNil;
911
- exports.isNull = isFunction.isNull;
912
- exports.isUndefined = isFunction.isUndefined;
1143
+ exports.isEqual = isWeakSet$1.isEqual;
1144
+ exports.isFunction = isWeakSet$1.isFunction;
1145
+ exports.isLength = isWeakSet$1.isLength;
1146
+ exports.isNil = isWeakSet$1.isNil;
1147
+ exports.isNotNil = isWeakSet$1.isNotNil;
1148
+ exports.isNull = isWeakSet$1.isNull;
1149
+ exports.isUndefined = isWeakSet$1.isUndefined;
913
1150
  exports.isPrimitive = isTypedArray$1.isPrimitive;
914
- exports.camelCase = string_index.camelCase;
915
1151
  exports.capitalize = string_index.capitalize;
916
1152
  exports.deburr = string_index.deburr;
1153
+ exports.escape = string_index.escape;
1154
+ exports.escapeRegExp = string_index.escapeRegExp;
917
1155
  exports.kebabCase = string_index.kebabCase;
918
1156
  exports.lowerCase = string_index.lowerCase;
919
1157
  exports.lowerFirst = string_index.lowerFirst;
1158
+ exports.pad = string_index.pad;
920
1159
  exports.pascalCase = string_index.pascalCase;
921
1160
  exports.snakeCase = string_index.snakeCase;
922
1161
  exports.startCase = string_index.startCase;
1162
+ exports.unescape = string_index.unescape;
923
1163
  exports.upperFirst = string_index.upperFirst;
924
1164
  exports.ary = ary;
1165
+ exports.attempt = attempt;
925
1166
  exports.bind = bind;
1167
+ exports.bindKey = bindKey;
1168
+ exports.camelCase = camelCase;
1169
+ exports.castArray = castArray;
926
1170
  exports.chunk = chunk;
927
1171
  exports.concat = concat;
1172
+ exports.conforms = conforms;
1173
+ exports.conformsTo = conformsTo;
928
1174
  exports.difference = difference;
929
1175
  exports.endsWith = endsWith;
930
1176
  exports.fill = fill;
931
1177
  exports.find = find;
932
1178
  exports.findIndex = findIndex;
1179
+ exports.findLastIndex = findLastIndex;
933
1180
  exports.flatten = flatten;
934
1181
  exports.flattenDeep = flattenDeep;
935
1182
  exports.flattenDepth = flattenDepth;
1183
+ exports.fromPairs = fromPairs;
936
1184
  exports.get = get;
937
1185
  exports.has = has;
938
1186
  exports.indexOf = indexOf;
@@ -941,11 +1189,15 @@ exports.isArray = isArray;
941
1189
  exports.isArrayLike = isArrayLike;
942
1190
  exports.isBoolean = isBoolean;
943
1191
  exports.isMatch = isMatch;
1192
+ exports.isObject = isObject;
944
1193
  exports.isPlainObject = isPlainObject;
945
1194
  exports.isRegExp = isRegExp;
946
1195
  exports.isString = isString;
947
1196
  exports.isSymbol = isSymbol;
948
1197
  exports.isTypedArray = isTypedArray;
1198
+ exports.isWeakMap = isWeakMap;
1199
+ exports.isWeakSet = isWeakSet;
1200
+ exports.join = join;
949
1201
  exports.mapKeys = mapKeys;
950
1202
  exports.mapValues = mapValues;
951
1203
  exports.matches = matches;
@@ -957,9 +1209,15 @@ exports.min = min;
957
1209
  exports.orderBy = orderBy;
958
1210
  exports.padEnd = padEnd;
959
1211
  exports.padStart = padStart;
1212
+ exports.parseInt = parseInt;
960
1213
  exports.property = property;
1214
+ exports.rearg = rearg;
1215
+ exports.repeat = repeat;
961
1216
  exports.rest = rest;
962
1217
  exports.set = set;
963
1218
  exports.size = size;
1219
+ exports.some = some;
1220
+ exports.sortBy = sortBy;
1221
+ exports.spread = spread;
964
1222
  exports.startsWith = startsWith;
965
1223
  exports.zipObjectDeep = zipObjectDeep;