@oscarpalmer/atoms 0.98.0 → 0.99.0

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 (239) hide show
  1. package/dist/array/group-by.cjs +27 -2
  2. package/dist/array/group-by.js +26 -2
  3. package/dist/array/index.cjs +19 -13
  4. package/dist/array/index.js +17 -6
  5. package/dist/array/insert.cjs +28 -2
  6. package/dist/array/insert.js +27 -2
  7. package/dist/{internal/array → array}/shuffle.cjs +3 -3
  8. package/dist/array/sort.cjs +24 -24
  9. package/dist/array/sort.js +22 -22
  10. package/dist/array/splice.cjs +2 -2
  11. package/dist/array/splice.js +1 -1
  12. package/dist/array/to-map.cjs +1 -1
  13. package/dist/array/to-map.js +1 -1
  14. package/dist/array/to-record.cjs +2 -2
  15. package/dist/array/to-record.js +1 -1
  16. package/dist/atoms.full.js +2745 -0
  17. package/dist/attoms.full.js +2840 -0
  18. package/dist/color.cjs +276 -0
  19. package/dist/color.js +263 -0
  20. package/dist/emitter.cjs +8 -8
  21. package/dist/emitter.js +1 -1
  22. package/dist/function.cjs +10 -9
  23. package/dist/function.js +6 -5
  24. package/dist/i18n.cjs +4 -6
  25. package/dist/i18n.js +4 -6
  26. package/dist/index.cjs +70 -77
  27. package/dist/index.js +27 -34
  28. package/dist/internal/array/callbacks.cjs +4 -1
  29. package/dist/internal/array/callbacks.js +4 -1
  30. package/dist/internal/array/find.cjs +4 -4
  31. package/dist/internal/array/find.js +4 -4
  32. package/dist/internal/math/aggregate.cjs +0 -4
  33. package/dist/internal/math/aggregate.js +1 -4
  34. package/dist/internal/string/key.cjs +10 -0
  35. package/dist/internal/string/key.js +6 -0
  36. package/dist/internal/value/{misc.cjs → handle.cjs} +2 -8
  37. package/dist/internal/value/{misc.js → handle.js} +2 -7
  38. package/dist/internal/value/paths.cjs +11 -0
  39. package/dist/internal/value/paths.js +7 -0
  40. package/dist/is.cjs +26 -8
  41. package/dist/is.js +21 -3
  42. package/dist/logger.cjs +9 -9
  43. package/dist/logger.js +1 -1
  44. package/dist/math.cjs +4 -1
  45. package/dist/math.js +4 -2
  46. package/dist/number.cjs +49 -6
  47. package/dist/number.js +48 -1
  48. package/dist/query.cjs +33 -32
  49. package/dist/query.js +30 -29
  50. package/dist/random.cjs +22 -9
  51. package/dist/random.js +16 -4
  52. package/dist/sized.cjs +2 -2
  53. package/dist/sized.js +1 -1
  54. package/dist/string/case.cjs +5 -5
  55. package/dist/string/case.js +1 -1
  56. package/dist/string/index.cjs +3 -4
  57. package/dist/string/index.js +1 -2
  58. package/dist/string/misc.cjs +26 -2
  59. package/dist/string/misc.js +24 -3
  60. package/dist/string/template.cjs +4 -4
  61. package/dist/string/template.js +2 -2
  62. package/dist/value/clone.cjs +2 -12
  63. package/dist/value/clone.js +1 -11
  64. package/dist/{internal/value → value}/compare.cjs +8 -8
  65. package/dist/{internal/value → value}/compare.js +3 -3
  66. package/dist/value/diff.cjs +10 -13
  67. package/dist/value/diff.js +4 -7
  68. package/dist/{internal/value → value}/equal.cjs +3 -3
  69. package/dist/{internal/value → value}/get.cjs +4 -3
  70. package/dist/{internal/value → value}/get.js +2 -1
  71. package/dist/value/index.cjs +21 -11
  72. package/dist/value/index.js +19 -5
  73. package/dist/value/merge.cjs +7 -24
  74. package/dist/value/merge.js +7 -24
  75. package/dist/{internal/value → value}/set.cjs +5 -4
  76. package/dist/{internal/value → value}/set.js +2 -1
  77. package/dist/value/smush.cjs +6 -6
  78. package/dist/value/smush.js +2 -2
  79. package/dist/value/unsmush.cjs +4 -4
  80. package/dist/value/unsmush.js +2 -2
  81. package/package.json +4 -3
  82. package/src/array/flatten.ts +3 -5
  83. package/src/array/index.ts +0 -1
  84. package/src/array/sort.ts +2 -2
  85. package/src/array/unique.ts +3 -5
  86. package/src/color/index.ts +0 -1
  87. package/src/color/is.ts +7 -7
  88. package/src/emitter.ts +0 -1
  89. package/src/function.ts +66 -45
  90. package/src/internal/is.ts +7 -0
  91. package/src/internal/number.ts +23 -1
  92. package/src/internal/random.ts +16 -14
  93. package/src/internal/value/get.ts +5 -0
  94. package/src/internal/value/misc.ts +11 -12
  95. package/src/internal/value/set.ts +7 -0
  96. package/src/is.ts +1 -7
  97. package/src/sized.ts +24 -32
  98. package/types/array/count.d.cts +0 -6
  99. package/types/array/exists.d.cts +0 -6
  100. package/types/array/filter.d.cts +0 -6
  101. package/types/array/find.d.cts +0 -6
  102. package/types/array/group-by.d.cts +2 -7
  103. package/types/array/group-by.d.ts +1 -0
  104. package/types/array/index-of.d.cts +0 -6
  105. package/types/array/index.d.cts +24 -40
  106. package/types/array/index.d.ts +17 -9
  107. package/types/array/insert.d.cts +2 -0
  108. package/types/array/insert.d.ts +2 -0
  109. package/types/array/models.d.cts +15 -15
  110. package/types/array/models.d.ts +15 -13
  111. package/types/array/sort.d.cts +9 -25
  112. package/types/array/sort.d.ts +8 -8
  113. package/types/array/to-map.d.cts +0 -6
  114. package/types/array/to-record.d.cts +1 -7
  115. package/types/array/unique.d.cts +0 -6
  116. package/types/{color/index.d.ts → color.d.ts} +26 -3
  117. package/types/function.d.cts +5 -5
  118. package/types/function.d.ts +6 -2
  119. package/types/index.d.cts +127 -157
  120. package/types/index.d.ts +1 -1
  121. package/types/internal/array/callbacks.d.cts +1 -1
  122. package/types/internal/array/callbacks.d.ts +1 -6
  123. package/types/internal/array/find.d.ts +1 -3
  124. package/types/internal/math/aggregate.d.cts +0 -19
  125. package/types/internal/math/aggregate.d.ts +0 -16
  126. package/types/internal/string/key.d.cts +5 -0
  127. package/types/internal/string/key.d.ts +1 -0
  128. package/types/internal/value/{misc.d.cts → handle.d.cts} +0 -4
  129. package/types/internal/value/{misc.d.ts → handle.d.ts} +0 -1
  130. package/types/internal/value/paths.d.cts +5 -0
  131. package/types/internal/value/paths.d.ts +1 -0
  132. package/types/is.d.cts +9 -21
  133. package/types/is.d.ts +14 -2
  134. package/types/math.d.cts +12 -15
  135. package/types/math.d.ts +16 -2
  136. package/types/models.d.cts +2 -14
  137. package/types/models.d.ts +2 -14
  138. package/types/number.d.ts +15 -1
  139. package/types/query.d.cts +0 -3
  140. package/types/random.d.cts +8 -8
  141. package/types/random.d.ts +8 -1
  142. package/types/string/index.d.cts +12 -15
  143. package/types/string/index.d.ts +0 -1
  144. package/types/string/misc.d.cts +12 -0
  145. package/types/string/misc.d.ts +12 -0
  146. package/types/string/template.d.cts +0 -3
  147. package/types/{internal/value → value}/get.d.cts +0 -3
  148. package/types/{internal/value → value}/get.d.ts +1 -1
  149. package/types/value/index.d.cts +39 -53
  150. package/types/value/index.d.ts +9 -5
  151. package/types/value/merge.d.cts +2 -13
  152. package/types/value/merge.d.ts +3 -8
  153. package/types/{internal/value → value}/set.d.cts +0 -3
  154. package/types/{internal/value → value}/set.d.ts +1 -1
  155. package/types/value/smush.d.cts +0 -3
  156. package/types/value/unsmush.d.cts +0 -3
  157. package/dist/array/flatten.cjs +0 -12
  158. package/dist/array/flatten.js +0 -8
  159. package/dist/array/push.cjs +0 -11
  160. package/dist/array/push.js +0 -7
  161. package/dist/color/constants.cjs +0 -33
  162. package/dist/color/constants.js +0 -22
  163. package/dist/color/get.cjs +0 -50
  164. package/dist/color/get.js +0 -46
  165. package/dist/color/index.cjs +0 -98
  166. package/dist/color/index.js +0 -85
  167. package/dist/color/is.cjs +0 -58
  168. package/dist/color/is.js +0 -51
  169. package/dist/color/misc.cjs +0 -16
  170. package/dist/color/misc.js +0 -12
  171. package/dist/color/models.cjs +0 -2
  172. package/dist/color/models.js +0 -1
  173. package/dist/color/value.cjs +0 -90
  174. package/dist/color/value.js +0 -83
  175. package/dist/internal/array/group.cjs +0 -32
  176. package/dist/internal/array/group.js +0 -28
  177. package/dist/internal/array/insert.cjs +0 -33
  178. package/dist/internal/array/insert.js +0 -29
  179. package/dist/internal/function.cjs +0 -8
  180. package/dist/internal/function.js +0 -4
  181. package/dist/internal/is.cjs +0 -41
  182. package/dist/internal/is.js +0 -34
  183. package/dist/internal/number.cjs +0 -54
  184. package/dist/internal/number.js +0 -48
  185. package/dist/internal/random.cjs +0 -21
  186. package/dist/internal/random.js +0 -16
  187. package/dist/internal/string.cjs +0 -50
  188. package/dist/internal/string.js +0 -41
  189. package/dist/value/partial.cjs +0 -18
  190. package/dist/value/partial.js +0 -14
  191. package/types/array/flatten.d.cts +0 -9
  192. package/types/array/flatten.d.ts +0 -5
  193. package/types/array/push.d.cts +0 -10
  194. package/types/array/push.d.ts +0 -6
  195. package/types/color/constants.d.cts +0 -23
  196. package/types/color/constants.d.ts +0 -9
  197. package/types/color/get.d.cts +0 -23
  198. package/types/color/get.d.ts +0 -5
  199. package/types/color/is.d.cts +0 -53
  200. package/types/color/is.d.ts +0 -18
  201. package/types/color/misc.d.cts +0 -8
  202. package/types/color/misc.d.ts +0 -4
  203. package/types/color/models.d.cts +0 -20
  204. package/types/color/models.d.ts +0 -16
  205. package/types/color/value.d.cts +0 -32
  206. package/types/color/value.d.ts +0 -19
  207. package/types/internal/array/group.d.cts +0 -9
  208. package/types/internal/array/group.d.ts +0 -2
  209. package/types/internal/array/insert.d.cts +0 -5
  210. package/types/internal/array/insert.d.ts +0 -1
  211. package/types/internal/function.d.cts +0 -8
  212. package/types/internal/function.d.ts +0 -4
  213. package/types/internal/is.d.cts +0 -33
  214. package/types/internal/is.d.ts +0 -17
  215. package/types/internal/number.d.cts +0 -19
  216. package/types/internal/number.d.ts +0 -15
  217. package/types/internal/random.d.cts +0 -12
  218. package/types/internal/random.d.ts +0 -8
  219. package/types/internal/string.d.cts +0 -19
  220. package/types/internal/string.d.ts +0 -15
  221. package/types/value/partial.d.cts +0 -12
  222. package/types/value/partial.d.ts +0 -5
  223. package/dist/{internal/array → array}/chunk.cjs +0 -0
  224. package/dist/{internal/array → array}/chunk.js +0 -0
  225. package/dist/{internal/array → array}/compact.cjs +0 -0
  226. package/dist/{internal/array → array}/compact.js +0 -0
  227. package/dist/{internal/array → array}/shuffle.js +0 -0
  228. package/dist/{internal/value → value}/equal.js +0 -0
  229. package/types/{internal/array → array}/chunk.d.cts +0 -0
  230. package/types/{internal/array → array}/chunk.d.ts +0 -0
  231. package/types/{internal/array → array}/compact.d.cts +0 -0
  232. package/types/{internal/array → array}/compact.d.ts +0 -0
  233. package/types/{internal/array → array}/shuffle.d.cts +0 -0
  234. package/types/{internal/array → array}/shuffle.d.ts +0 -0
  235. package/types/{color/index.d.cts → color.d.cts} +16 -16
  236. /package/types/{internal/value → value}/compare.d.cts +0 -0
  237. /package/types/{internal/value → value}/compare.d.ts +0 -0
  238. /package/types/{internal/value → value}/equal.d.cts +0 -0
  239. /package/types/{internal/value → value}/equal.d.ts +0 -0
@@ -2,15 +2,40 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_array_group = require('../internal/array/group.cjs');
5
+ const internal_array_callbacks = require('../internal/array/callbacks.cjs');
6
6
 
7
7
  function groupBy(array, key, valueOrArrays, arrays) {
8
- return internal_array_group.groupValues(
8
+ return groupValues(
9
9
  array,
10
10
  key,
11
11
  valueOrArrays,
12
12
  key === true || valueOrArrays === true || arrays === true
13
13
  );
14
14
  }
15
+ function groupValues(array, key, value, arrays) {
16
+ if (!Array.isArray(array) || array.length === 0) {
17
+ return {};
18
+ }
19
+ const callbacks = internal_array_callbacks.getCallbacks(void 0, key, value);
20
+ const record = {};
21
+ const { length } = array;
22
+ for (let index = 0; index < length; index += 1) {
23
+ const item = array[index];
24
+ const keyed = callbacks?.key?.(item, index, array) ?? index;
25
+ const valued = callbacks?.value?.(item, index, array) ?? item;
26
+ if (arrays) {
27
+ const existing = record[keyed];
28
+ if (existing == null) {
29
+ record[keyed] = [valued];
30
+ } else {
31
+ existing.push(valued);
32
+ }
33
+ } else {
34
+ record[keyed] = valued;
35
+ }
36
+ }
37
+ return record;
38
+ }
15
39
 
16
40
  exports.groupBy = groupBy;
41
+ exports.groupValues = groupValues;
@@ -1,4 +1,4 @@
1
- import { groupValues } from '../internal/array/group.js';
1
+ import { getCallbacks } from '../internal/array/callbacks.js';
2
2
 
3
3
  function groupBy(array, key, valueOrArrays, arrays) {
4
4
  return groupValues(
@@ -8,5 +8,29 @@ function groupBy(array, key, valueOrArrays, arrays) {
8
8
  key === true || valueOrArrays === true || arrays === true
9
9
  );
10
10
  }
11
+ function groupValues(array, key, value, arrays) {
12
+ if (!Array.isArray(array) || array.length === 0) {
13
+ return {};
14
+ }
15
+ const callbacks = getCallbacks(void 0, key, value);
16
+ const record = {};
17
+ const { length } = array;
18
+ for (let index = 0; index < length; index += 1) {
19
+ const item = array[index];
20
+ const keyed = callbacks?.key?.(item, index, array) ?? index;
21
+ const valued = callbacks?.value?.(item, index, array) ?? item;
22
+ if (arrays) {
23
+ const existing = record[keyed];
24
+ if (existing == null) {
25
+ record[keyed] = [valued];
26
+ } else {
27
+ existing.push(valued);
28
+ }
29
+ } else {
30
+ record[keyed] = valued;
31
+ }
32
+ }
33
+ return record;
34
+ }
11
35
 
12
- export { groupBy };
36
+ export { groupBy, groupValues };
@@ -2,40 +2,46 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_array_chunk = require('../internal/array/chunk.cjs');
6
- const internal_array_compact = require('../internal/array/compact.cjs');
7
- const internal_array_shuffle = require('../internal/array/shuffle.cjs');
5
+ const array_insert = require('./insert.cjs');
6
+ const array_chunk = require('./chunk.cjs');
7
+ const array_compact = require('./compact.cjs');
8
8
  const array_count = require('./count.cjs');
9
9
  const array_exists = require('./exists.cjs');
10
10
  const array_filter = require('./filter.cjs');
11
11
  const array_find = require('./find.cjs');
12
- const array_flatten = require('./flatten.cjs');
13
12
  const array_groupBy = require('./group-by.cjs');
14
13
  const array_indexOf = require('./index-of.cjs');
15
- const array_insert = require('./insert.cjs');
16
- const array_push = require('./push.cjs');
14
+ const array_shuffle = require('./shuffle.cjs');
17
15
  const array_sort = require('./sort.cjs');
18
16
  const array_splice = require('./splice.cjs');
19
17
  const array_toMap = require('./to-map.cjs');
20
18
  const array_toRecord = require('./to-record.cjs');
21
19
  const array_unique = require('./unique.cjs');
22
20
 
21
+ function flatten(array) {
22
+ if (!Array.isArray(array)) {
23
+ return [];
24
+ }
25
+ return array.flat(Number.POSITIVE_INFINITY);
26
+ }
27
+ function push(array, pushed) {
28
+ return array_insert.insertValues("push", array, pushed, array.length, 0);
29
+ }
23
30
 
24
-
25
- exports.chunk = internal_array_chunk.chunk;
26
- exports.compact = internal_array_compact.compact;
27
- exports.shuffle = internal_array_shuffle.shuffle;
31
+ exports.insert = array_insert.insert;
32
+ exports.chunk = array_chunk.chunk;
33
+ exports.compact = array_compact.compact;
28
34
  exports.count = array_count.count;
29
35
  exports.exists = array_exists.exists;
30
36
  exports.filter = array_filter.filter;
31
37
  exports.find = array_find.find;
32
- exports.flatten = array_flatten.flatten;
33
38
  exports.groupBy = array_groupBy.groupBy;
34
39
  exports.indexOf = array_indexOf.indexOf;
35
- exports.insert = array_insert.insert;
36
- exports.push = array_push.push;
40
+ exports.shuffle = array_shuffle.shuffle;
37
41
  exports.sort = array_sort.sort;
38
42
  exports.splice = array_splice.splice;
39
43
  exports.toMap = array_toMap.toMap;
40
44
  exports.toRecord = array_toRecord.toRecord;
41
45
  exports.unique = array_unique.unique;
46
+ exports.flatten = flatten;
47
+ exports.push = push;
@@ -1,17 +1,28 @@
1
- export { chunk } from '../internal/array/chunk.js';
2
- export { compact } from '../internal/array/compact.js';
3
- export { shuffle } from '../internal/array/shuffle.js';
1
+ import { insertValues } from './insert.js';
2
+ export { insert } from './insert.js';
3
+ export { chunk } from './chunk.js';
4
+ export { compact } from './compact.js';
4
5
  export { count } from './count.js';
5
6
  export { exists } from './exists.js';
6
7
  export { filter } from './filter.js';
7
8
  export { find } from './find.js';
8
- export { flatten } from './flatten.js';
9
9
  export { groupBy } from './group-by.js';
10
10
  export { indexOf } from './index-of.js';
11
- export { insert } from './insert.js';
12
- export { push } from './push.js';
11
+ export { shuffle } from './shuffle.js';
13
12
  export { sort } from './sort.js';
14
13
  export { splice } from './splice.js';
15
14
  export { toMap } from './to-map.js';
16
15
  export { toRecord } from './to-record.js';
17
16
  export { unique } from './unique.js';
17
+
18
+ function flatten(array) {
19
+ if (!Array.isArray(array)) {
20
+ return [];
21
+ }
22
+ return array.flat(Number.POSITIVE_INFINITY);
23
+ }
24
+ function push(array, pushed) {
25
+ return insertValues("push", array, pushed, array.length, 0);
26
+ }
27
+
28
+ export { flatten, push };
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_array_insert = require('../internal/array/insert.cjs');
5
+ const array_chunk = require('./chunk.cjs');
6
6
 
7
7
  function insert(array, indexOrItems, items) {
8
- return internal_array_insert.insertValues(
8
+ return insertValues(
9
9
  "insert",
10
10
  array,
11
11
  items == null ? indexOrItems : items,
@@ -13,5 +13,31 @@ function insert(array, indexOrItems, items) {
13
13
  0
14
14
  );
15
15
  }
16
+ function insertValues(type, array, items, start, deleteCount) {
17
+ const splice = type === "insert" || type === "splice";
18
+ if (!Array.isArray(array) || typeof start !== "number") {
19
+ return splice ? [] : 0;
20
+ }
21
+ if (!Array.isArray(items) || items.length === 0) {
22
+ return splice ? [] : 0;
23
+ }
24
+ const actualStart = Math.min(Math.max(0, start), array.length);
25
+ const chunked = array_chunk.chunk(items);
26
+ const lastIndex = chunked.length - 1;
27
+ let index = Number(chunked.length);
28
+ let returned;
29
+ while (--index >= 0) {
30
+ const result = array.splice(
31
+ actualStart,
32
+ index === lastIndex ? deleteCount < 0 ? 0 : deleteCount : 0,
33
+ ...chunked[index]
34
+ );
35
+ if (returned == null) {
36
+ returned = result;
37
+ }
38
+ }
39
+ return type === "insert" ? array : type === "splice" ? returned : array.length;
40
+ }
16
41
 
17
42
  exports.insert = insert;
43
+ exports.insertValues = insertValues;
@@ -1,4 +1,4 @@
1
- import { insertValues } from '../internal/array/insert.js';
1
+ import { chunk } from './chunk.js';
2
2
 
3
3
  function insert(array, indexOrItems, items) {
4
4
  return insertValues(
@@ -9,5 +9,30 @@ function insert(array, indexOrItems, items) {
9
9
  0
10
10
  );
11
11
  }
12
+ function insertValues(type, array, items, start, deleteCount) {
13
+ const splice = type === "insert" || type === "splice";
14
+ if (!Array.isArray(array) || typeof start !== "number") {
15
+ return splice ? [] : 0;
16
+ }
17
+ if (!Array.isArray(items) || items.length === 0) {
18
+ return splice ? [] : 0;
19
+ }
20
+ const actualStart = Math.min(Math.max(0, start), array.length);
21
+ const chunked = chunk(items);
22
+ const lastIndex = chunked.length - 1;
23
+ let index = Number(chunked.length);
24
+ let returned;
25
+ while (--index >= 0) {
26
+ const result = array.splice(
27
+ actualStart,
28
+ index === lastIndex ? deleteCount < 0 ? 0 : deleteCount : 0,
29
+ ...chunked[index]
30
+ );
31
+ if (returned == null) {
32
+ returned = result;
33
+ }
34
+ }
35
+ return type === "insert" ? array : type === "splice" ? returned : array.length;
36
+ }
12
37
 
13
- export { insert };
38
+ export { insert, insertValues };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_random = require('../random.cjs');
5
+ const random = require('../random.cjs');
6
6
 
7
7
  function shuffle(array) {
8
8
  if (!Array.isArray(array)) {
@@ -14,8 +14,8 @@ function shuffle(array) {
14
14
  const shuffled = array.slice();
15
15
  let index = Number(shuffled.length);
16
16
  while (--index >= 0) {
17
- const random = internal_random.getRandomInteger(0, index);
18
- [shuffled[index], shuffled[random]] = [shuffled[random], shuffled[index]];
17
+ const random$1 = random.getRandomInteger(0, index);
18
+ [shuffled[index], shuffled[random$1]] = [shuffled[random$1], shuffled[index]];
19
19
  }
20
20
  return shuffled;
21
21
  }
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_is = require('../internal/is.cjs');
6
- const internal_value_compare = require('../internal/value/compare.cjs');
5
+ const is = require('../is.cjs');
6
+ const value_compare = require('../value/compare.cjs');
7
7
 
8
8
  function sort(array, first, second) {
9
9
  if (!Array.isArray(array)) {
@@ -13,48 +13,48 @@ function sort(array, first, second) {
13
13
  return array;
14
14
  }
15
15
  const direction = first === true || second === true ? "desc" : "asc";
16
- const unknownSorters = Array.isArray(first) ? first : [first];
17
- let { length } = unknownSorters;
18
- const sorters = [];
16
+ const unknownKeys = Array.isArray(first) ? first : [first];
17
+ let { length } = unknownKeys;
18
+ const keys = [];
19
19
  for (let index = 0; index < length; index += 1) {
20
- const unknownSorter = unknownSorters[index];
21
- const sorter = {
20
+ const key = unknownKeys[index];
21
+ const keyWithCallback = {
22
22
  direction,
23
23
  callback: void 0
24
24
  };
25
- if (internal_is.isKey(unknownSorter)) {
26
- sorter.callback = (value) => value[unknownSorter];
27
- } else if (typeof unknownSorter === "function") {
28
- sorter.callback = unknownSorter;
29
- } else if (typeof unknownSorter?.value === "function" || internal_is.isKey(unknownSorter?.value)) {
30
- sorter.direction = unknownSorter?.direction ?? direction;
31
- sorter.callback = typeof unknownSorter.value === "function" ? unknownSorter.value : (value) => value[unknownSorter.value];
25
+ if (is.isKey(key)) {
26
+ keyWithCallback.callback = (value) => value[key];
27
+ } else if (typeof key === "function") {
28
+ keyWithCallback.callback = key;
29
+ } else if (typeof key?.value === "function" || is.isKey(key?.value)) {
30
+ keyWithCallback.direction = key?.direction ?? direction;
31
+ keyWithCallback.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
32
32
  }
33
- if (typeof sorter.callback === "function") {
34
- const existing = sorters.findIndex(
35
- (existing2) => existing2.callback.toString() === sorter.callback.toString()
33
+ if (typeof keyWithCallback.callback === "function") {
34
+ const existing = keys.findIndex(
35
+ (existing2) => existing2.callback.toString() === keyWithCallback.callback.toString()
36
36
  );
37
37
  if (existing > -1) {
38
- sorters.splice(existing, 1);
38
+ keys.splice(existing, 1);
39
39
  }
40
- sorters.push(sorter);
40
+ keys.push(keyWithCallback);
41
41
  }
42
42
  }
43
- length = sorters.length;
43
+ length = keys.length;
44
44
  if (length === 0) {
45
45
  return array.sort(
46
- (first2, second2) => internal_value_compare.compare(first2, second2) * (direction === "asc" ? 1 : -1)
46
+ (first2, second2) => value_compare.compare(first2, second2) * (direction === "asc" ? 1 : -1)
47
47
  );
48
48
  }
49
49
  if (length === 1) {
50
50
  return array.sort(
51
- (first2, second2) => internal_value_compare.compare(sorters[0].callback(first2), sorters[0].callback(second2)) * (sorters[0].direction === "asc" ? 1 : -1)
51
+ (first2, second2) => value_compare.compare(keys[0].callback(first2), keys[0].callback(second2)) * (keys[0].direction === "asc" ? 1 : -1)
52
52
  );
53
53
  }
54
54
  const sorted = array.sort((first2, second2) => {
55
55
  for (let index = 0; index < length; index += 1) {
56
- const { callback, direction: direction2 } = sorters[index];
57
- const compared = internal_value_compare.compare(callback(first2), callback(second2)) * (direction2 === "asc" ? 1 : -1);
56
+ const { callback, direction: direction2 } = keys[index];
57
+ const compared = value_compare.compare(callback(first2), callback(second2)) * (direction2 === "asc" ? 1 : -1);
58
58
  if (compared !== 0) {
59
59
  return compared;
60
60
  }
@@ -1,5 +1,5 @@
1
- import { isKey } from '../internal/is.js';
2
- import { compare } from '../internal/value/compare.js';
1
+ import { isKey } from '../is.js';
2
+ import { compare } from '../value/compare.js';
3
3
 
4
4
  function sort(array, first, second) {
5
5
  if (!Array.isArray(array)) {
@@ -9,34 +9,34 @@ function sort(array, first, second) {
9
9
  return array;
10
10
  }
11
11
  const direction = first === true || second === true ? "desc" : "asc";
12
- const unknownSorters = Array.isArray(first) ? first : [first];
13
- let { length } = unknownSorters;
14
- const sorters = [];
12
+ const unknownKeys = Array.isArray(first) ? first : [first];
13
+ let { length } = unknownKeys;
14
+ const keys = [];
15
15
  for (let index = 0; index < length; index += 1) {
16
- const unknownSorter = unknownSorters[index];
17
- const sorter = {
16
+ const key = unknownKeys[index];
17
+ const keyWithCallback = {
18
18
  direction,
19
19
  callback: void 0
20
20
  };
21
- if (isKey(unknownSorter)) {
22
- sorter.callback = (value) => value[unknownSorter];
23
- } else if (typeof unknownSorter === "function") {
24
- sorter.callback = unknownSorter;
25
- } else if (typeof unknownSorter?.value === "function" || isKey(unknownSorter?.value)) {
26
- sorter.direction = unknownSorter?.direction ?? direction;
27
- sorter.callback = typeof unknownSorter.value === "function" ? unknownSorter.value : (value) => value[unknownSorter.value];
21
+ if (isKey(key)) {
22
+ keyWithCallback.callback = (value) => value[key];
23
+ } else if (typeof key === "function") {
24
+ keyWithCallback.callback = key;
25
+ } else if (typeof key?.value === "function" || isKey(key?.value)) {
26
+ keyWithCallback.direction = key?.direction ?? direction;
27
+ keyWithCallback.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
28
28
  }
29
- if (typeof sorter.callback === "function") {
30
- const existing = sorters.findIndex(
31
- (existing2) => existing2.callback.toString() === sorter.callback.toString()
29
+ if (typeof keyWithCallback.callback === "function") {
30
+ const existing = keys.findIndex(
31
+ (existing2) => existing2.callback.toString() === keyWithCallback.callback.toString()
32
32
  );
33
33
  if (existing > -1) {
34
- sorters.splice(existing, 1);
34
+ keys.splice(existing, 1);
35
35
  }
36
- sorters.push(sorter);
36
+ keys.push(keyWithCallback);
37
37
  }
38
38
  }
39
- length = sorters.length;
39
+ length = keys.length;
40
40
  if (length === 0) {
41
41
  return array.sort(
42
42
  (first2, second2) => compare(first2, second2) * (direction === "asc" ? 1 : -1)
@@ -44,12 +44,12 @@ function sort(array, first, second) {
44
44
  }
45
45
  if (length === 1) {
46
46
  return array.sort(
47
- (first2, second2) => compare(sorters[0].callback(first2), sorters[0].callback(second2)) * (sorters[0].direction === "asc" ? 1 : -1)
47
+ (first2, second2) => compare(keys[0].callback(first2), keys[0].callback(second2)) * (keys[0].direction === "asc" ? 1 : -1)
48
48
  );
49
49
  }
50
50
  const sorted = array.sort((first2, second2) => {
51
51
  for (let index = 0; index < length; index += 1) {
52
- const { callback, direction: direction2 } = sorters[index];
52
+ const { callback, direction: direction2 } = keys[index];
53
53
  const compared = compare(callback(first2), callback(second2)) * (direction2 === "asc" ? 1 : -1);
54
54
  if (compared !== 0) {
55
55
  return compared;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_array_insert = require('../internal/array/insert.cjs');
5
+ const array_insert = require('./insert.cjs');
6
6
 
7
7
  function splice(array, start, deleteCountOrItems, items) {
8
- return internal_array_insert.insertValues(
8
+ return array_insert.insertValues(
9
9
  "splice",
10
10
  array,
11
11
  typeof deleteCountOrItems === "number" ? items : deleteCountOrItems,
@@ -1,4 +1,4 @@
1
- import { insertValues } from '../internal/array/insert.js';
1
+ import { insertValues } from './insert.js';
2
2
 
3
3
  function splice(array, start, deleteCountOrItems, items) {
4
4
  return insertValues(
@@ -14,7 +14,7 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
14
14
  const { length } = array;
15
15
  for (let index = 0; index < length; index += 1) {
16
16
  const item = array[index];
17
- const key = callbacks?.keyed?.(item, index, array) ?? index;
17
+ const key = callbacks?.key?.(item, index, array) ?? index;
18
18
  const value = callbacks?.value?.(item, index, array) ?? item;
19
19
  if (asArrays) {
20
20
  const existing = map.get(key);
@@ -10,7 +10,7 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
10
10
  const { length } = array;
11
11
  for (let index = 0; index < length; index += 1) {
12
12
  const item = array[index];
13
- const key = callbacks?.keyed?.(item, index, array) ?? index;
13
+ const key = callbacks?.key?.(item, index, array) ?? index;
14
14
  const value = callbacks?.value?.(item, index, array) ?? item;
15
15
  if (asArrays) {
16
16
  const existing = map.get(key);
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const internal_array_group = require('../internal/array/group.cjs');
5
+ const array_groupBy = require('./group-by.cjs');
6
6
 
7
7
  function toRecord(array, key, valueOrArrays, arrays) {
8
- return internal_array_group.groupValues(
8
+ return array_groupBy.groupValues(
9
9
  array,
10
10
  key,
11
11
  valueOrArrays,
@@ -1,4 +1,4 @@
1
- import { groupValues } from '../internal/array/group.js';
1
+ import { groupValues } from './group-by.js';
2
2
 
3
3
  function toRecord(array, key, valueOrArrays, arrays) {
4
4
  return groupValues(