@oscarpalmer/atoms 0.101.0 → 0.103.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 (188) hide show
  1. package/dist/array/count.cjs +11 -23
  2. package/dist/array/count.js +11 -19
  3. package/dist/array/exists.cjs +3 -11
  4. package/dist/array/exists.js +3 -7
  5. package/dist/array/filter.cjs +2 -8
  6. package/dist/array/filter.js +2 -4
  7. package/dist/array/find.cjs +2 -8
  8. package/dist/array/find.js +2 -4
  9. package/dist/array/flatten.cjs +4 -6
  10. package/dist/array/flatten.js +4 -2
  11. package/dist/array/get.cjs +17 -0
  12. package/dist/array/get.js +17 -0
  13. package/dist/array/group-by.cjs +2 -13
  14. package/dist/array/group-by.js +2 -9
  15. package/dist/array/index-of.cjs +2 -8
  16. package/dist/array/index-of.js +2 -4
  17. package/dist/array/index.cjs +36 -41
  18. package/dist/array/index.js +19 -17
  19. package/dist/array/insert.cjs +2 -14
  20. package/dist/array/insert.js +2 -10
  21. package/dist/array/models.cjs +0 -2
  22. package/dist/array/models.js +0 -1
  23. package/dist/array/push.cjs +7 -8
  24. package/dist/array/push.js +7 -4
  25. package/dist/array/sort.cjs +43 -62
  26. package/dist/array/sort.js +43 -58
  27. package/dist/array/splice.cjs +2 -14
  28. package/dist/array/splice.js +2 -10
  29. package/dist/array/to-map.cjs +17 -30
  30. package/dist/array/to-map.js +17 -26
  31. package/dist/array/to-record.cjs +2 -13
  32. package/dist/array/to-record.js +2 -9
  33. package/dist/array/unique.cjs +3 -11
  34. package/dist/array/unique.js +3 -7
  35. package/dist/color/constants.cjs +15 -16
  36. package/dist/color/constants.js +15 -12
  37. package/dist/color/get.cjs +44 -47
  38. package/dist/color/get.js +44 -43
  39. package/dist/color/index.cjs +90 -83
  40. package/dist/color/index.js +87 -75
  41. package/dist/color/is.cjs +39 -36
  42. package/dist/color/is.js +39 -32
  43. package/dist/color/misc.cjs +8 -13
  44. package/dist/color/misc.js +8 -9
  45. package/dist/color/models.cjs +0 -2
  46. package/dist/color/models.js +0 -1
  47. package/dist/color/value.cjs +76 -76
  48. package/dist/color/value.js +76 -72
  49. package/dist/emitter.cjs +142 -162
  50. package/dist/emitter.js +142 -158
  51. package/dist/function.cjs +119 -123
  52. package/dist/function.js +119 -120
  53. package/dist/index.cjs +139 -144
  54. package/dist/index.js +52 -48
  55. package/dist/internal/array/callbacks.cjs +10 -19
  56. package/dist/internal/array/callbacks.js +10 -15
  57. package/dist/internal/array/chunk.cjs +15 -23
  58. package/dist/internal/array/chunk.js +15 -19
  59. package/dist/internal/array/compact.cjs +9 -18
  60. package/dist/internal/array/compact.js +9 -14
  61. package/dist/internal/array/find.cjs +41 -63
  62. package/dist/internal/array/find.js +41 -59
  63. package/dist/internal/array/group.cjs +16 -29
  64. package/dist/internal/array/group.js +16 -25
  65. package/dist/internal/array/insert.cjs +14 -30
  66. package/dist/internal/array/insert.js +14 -26
  67. package/dist/internal/array/shuffle.cjs +13 -20
  68. package/dist/internal/array/shuffle.js +13 -16
  69. package/dist/internal/function.cjs +28 -26
  70. package/dist/internal/function.js +21 -21
  71. package/dist/internal/is.cjs +35 -29
  72. package/dist/internal/is.js +35 -25
  73. package/dist/internal/math/aggregate.cjs +29 -36
  74. package/dist/internal/math/aggregate.js +29 -32
  75. package/dist/internal/number.cjs +34 -53
  76. package/dist/internal/number.js +34 -49
  77. package/dist/internal/random.cjs +13 -17
  78. package/dist/internal/random.js +13 -13
  79. package/dist/internal/string.cjs +25 -28
  80. package/dist/internal/string.js +25 -24
  81. package/dist/internal/value/compare.cjs +41 -69
  82. package/dist/internal/value/compare.js +41 -65
  83. package/dist/internal/value/equal.cjs +76 -154
  84. package/dist/internal/value/equal.js +76 -150
  85. package/dist/internal/value/get.cjs +10 -28
  86. package/dist/internal/value/get.js +10 -24
  87. package/dist/internal/value/misc.cjs +13 -23
  88. package/dist/internal/value/misc.js +13 -19
  89. package/dist/internal/value/set.cjs +29 -39
  90. package/dist/internal/value/set.js +29 -35
  91. package/dist/is.cjs +38 -27
  92. package/dist/is.js +34 -20
  93. package/dist/logger.cjs +97 -107
  94. package/dist/logger.js +97 -103
  95. package/dist/math.cjs +13 -20
  96. package/dist/math.js +13 -17
  97. package/dist/models.cjs +0 -2
  98. package/dist/models.js +0 -1
  99. package/dist/number.cjs +4 -11
  100. package/dist/number.js +2 -1
  101. package/dist/query.cjs +53 -71
  102. package/dist/query.js +53 -67
  103. package/dist/random.cjs +37 -33
  104. package/dist/random.js +36 -29
  105. package/dist/sized.cjs +93 -111
  106. package/dist/sized.js +93 -107
  107. package/dist/string/case.cjs +49 -51
  108. package/dist/string/case.js +49 -47
  109. package/dist/string/index.cjs +17 -24
  110. package/dist/string/index.js +5 -4
  111. package/dist/string/misc.cjs +26 -24
  112. package/dist/string/misc.js +26 -20
  113. package/dist/string/template.cjs +17 -26
  114. package/dist/string/template.js +17 -22
  115. package/dist/touch.cjs +18 -27
  116. package/dist/touch.js +18 -25
  117. package/dist/value/clone.cjs +75 -123
  118. package/dist/value/clone.js +75 -119
  119. package/dist/value/diff.cjs +83 -94
  120. package/dist/value/diff.js +83 -90
  121. package/dist/value/index.cjs +20 -27
  122. package/dist/value/index.js +11 -10
  123. package/dist/value/merge.cjs +33 -53
  124. package/dist/value/merge.js +33 -49
  125. package/dist/value/partial.cjs +11 -15
  126. package/dist/value/partial.js +11 -11
  127. package/dist/value/smush.cjs +22 -32
  128. package/dist/value/smush.js +22 -28
  129. package/dist/value/unsmush.cjs +26 -35
  130. package/dist/value/unsmush.js +26 -31
  131. package/package.json +4 -14
  132. package/src/array/flatten.ts +3 -3
  133. package/src/array/get.ts +62 -0
  134. package/src/array/index.ts +1 -0
  135. package/src/array/models.ts +13 -0
  136. package/src/array/sort.ts +1 -1
  137. package/src/color/index.ts +11 -3
  138. package/src/color/is.ts +2 -0
  139. package/src/function.ts +1 -0
  140. package/src/index.ts +0 -1
  141. package/src/internal/function.ts +2 -0
  142. package/src/internal/is.ts +2 -0
  143. package/src/internal/string.ts +2 -0
  144. package/src/internal/value/compare.ts +2 -0
  145. package/src/internal/value/set.ts +2 -0
  146. package/src/is.ts +7 -0
  147. package/src/logger.ts +1 -1
  148. package/src/math.ts +1 -1
  149. package/src/models.ts +2 -2
  150. package/src/query.ts +6 -0
  151. package/src/random.ts +0 -1
  152. package/src/string/case.ts +2 -0
  153. package/src/string/index.ts +1 -0
  154. package/src/string/misc.ts +2 -0
  155. package/src/string/template.ts +4 -2
  156. package/src/value/index.ts +1 -1
  157. package/src/value/merge.ts +1 -1
  158. package/types/array/flatten.d.cts +2 -2
  159. package/types/array/flatten.d.ts +2 -2
  160. package/types/array/get.d.cts +34 -0
  161. package/types/array/get.d.ts +22 -0
  162. package/types/array/index.d.cts +56 -30
  163. package/types/array/index.d.ts +1 -0
  164. package/types/array/models.d.cts +16 -0
  165. package/types/array/models.d.ts +7 -0
  166. package/types/color/index.d.ts +3 -3
  167. package/types/function.d.cts +1 -1
  168. package/types/function.d.ts +1 -0
  169. package/types/index.d.cts +61 -66
  170. package/types/index.d.ts +0 -1
  171. package/types/is.d.ts +1 -0
  172. package/types/logger.d.cts +2 -2
  173. package/types/logger.d.ts +1 -1
  174. package/types/math.d.ts +1 -1
  175. package/types/models.d.cts +1 -1
  176. package/types/models.d.ts +1 -1
  177. package/types/query.d.ts +1 -0
  178. package/types/string/index.d.cts +2 -2
  179. package/types/string/index.d.ts +1 -0
  180. package/types/string/template.d.cts +2 -2
  181. package/types/string/template.d.ts +2 -3
  182. package/types/value/index.d.ts +1 -0
  183. package/types/value/merge.d.ts +1 -2
  184. package/dist/i18n.cjs +0 -146
  185. package/dist/i18n.js +0 -142
  186. package/src/i18n.ts +0 -325
  187. package/types/i18n.d.cts +0 -35
  188. package/types/i18n.d.ts +0 -32
@@ -1,26 +1,14 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_find = require('../internal/array/find.cjs');
6
-
1
+ const require_internal_array_find = require("../internal/array/find.cjs");
7
2
  function count(array, ...parameters) {
8
- if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
9
- if (!Array.isArray(array)) {
10
- return Number.NaN;
11
- }
12
- const { length } = array;
13
- if (length === 0) {
14
- return 0;
15
- }
16
- const value = parameters[0];
17
- let result = 0;
18
- for (let index = 0; index < length; index += 1) {
19
- result += Object.is(array[index], value) ? 1 : 0;
20
- }
21
- return result;
22
- }
23
- return internal_array_find.findValues("all", array, parameters, true)?.length ?? Number.NaN;
3
+ if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
4
+ if (!Array.isArray(array)) return NaN;
5
+ const { length } = array;
6
+ if (length === 0) return 0;
7
+ const value = parameters[0];
8
+ let result = 0;
9
+ for (let index = 0; index < length; index += 1) result += Object.is(array[index], value) ? 1 : 0;
10
+ return result;
11
+ }
12
+ return require_internal_array_find.findValues("all", array, parameters, true)?.length ?? NaN;
24
13
  }
25
-
26
14
  exports.count = count;
@@ -1,22 +1,14 @@
1
- import { findValues } from '../internal/array/find.js';
2
-
1
+ import { findValues } from "../internal/array/find.js";
3
2
  function count(array, ...parameters) {
4
- if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
5
- if (!Array.isArray(array)) {
6
- return Number.NaN;
7
- }
8
- const { length } = array;
9
- if (length === 0) {
10
- return 0;
11
- }
12
- const value = parameters[0];
13
- let result = 0;
14
- for (let index = 0; index < length; index += 1) {
15
- result += Object.is(array[index], value) ? 1 : 0;
16
- }
17
- return result;
18
- }
19
- return findValues("all", array, parameters, true)?.length ?? Number.NaN;
3
+ if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
4
+ if (!Array.isArray(array)) return NaN;
5
+ const { length } = array;
6
+ if (length === 0) return 0;
7
+ const value = parameters[0];
8
+ let result = 0;
9
+ for (let index = 0; index < length; index += 1) result += Object.is(array[index], value) ? 1 : 0;
10
+ return result;
11
+ }
12
+ return findValues("all", array, parameters, true)?.length ?? NaN;
20
13
  }
21
-
22
14
  export { count };
@@ -1,14 +1,6 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_find = require('../internal/array/find.cjs');
6
-
1
+ const require_internal_array_find = require("../internal/array/find.cjs");
7
2
  function exists(array, ...parameters) {
8
- if (parameters.length === 1 && typeof parameters[0] !== "function") {
9
- return Array.isArray(array) ? array.includes(parameters[0]) : false;
10
- }
11
- return internal_array_find.findValue("index", array, parameters) > -1;
3
+ if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
4
+ return require_internal_array_find.findValue("index", array, parameters) > -1;
12
5
  }
13
-
14
6
  exports.exists = exists;
@@ -1,10 +1,6 @@
1
- import { findValue } from '../internal/array/find.js';
2
-
1
+ import { findValue } from "../internal/array/find.js";
3
2
  function exists(array, ...parameters) {
4
- if (parameters.length === 1 && typeof parameters[0] !== "function") {
5
- return Array.isArray(array) ? array.includes(parameters[0]) : false;
6
- }
7
- return findValue("index", array, parameters) > -1;
3
+ if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
4
+ return findValue("index", array, parameters) > -1;
8
5
  }
9
-
10
6
  export { exists };
@@ -1,11 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_find = require('../internal/array/find.cjs');
6
-
1
+ const require_internal_array_find = require("../internal/array/find.cjs");
7
2
  function filter(array, ...parameters) {
8
- return internal_array_find.findValues("all", array, parameters);
3
+ return require_internal_array_find.findValues("all", array, parameters);
9
4
  }
10
-
11
5
  exports.filter = filter;
@@ -1,7 +1,5 @@
1
- import { findValues } from '../internal/array/find.js';
2
-
1
+ import { findValues } from "../internal/array/find.js";
3
2
  function filter(array, ...parameters) {
4
- return findValues("all", array, parameters);
3
+ return findValues("all", array, parameters);
5
4
  }
6
-
7
5
  export { filter };
@@ -1,11 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_find = require('../internal/array/find.cjs');
6
-
1
+ const require_internal_array_find = require("../internal/array/find.cjs");
7
2
  function find(array, ...parameters) {
8
- return internal_array_find.findValue("value", array, parameters);
3
+ return require_internal_array_find.findValue("value", array, parameters);
9
4
  }
10
-
11
5
  exports.find = find;
@@ -1,7 +1,5 @@
1
- import { findValue } from '../internal/array/find.js';
2
-
1
+ import { findValue } from "../internal/array/find.js";
3
2
  function find(array, ...parameters) {
4
- return findValue("value", array, parameters);
3
+ return findValue("value", array, parameters);
5
4
  }
6
-
7
5
  export { find };
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
1
+ /**
2
+ * Flatten an array _(using native `flat` and maximum depth)_
3
+ */
5
4
  function flatten(array) {
6
- return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
5
+ return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
7
6
  }
8
-
9
7
  exports.flatten = flatten;
@@ -1,5 +1,7 @@
1
+ /**
2
+ * Flatten an array _(using native `flat` and maximum depth)_
3
+ */
1
4
  function flatten(array) {
2
- return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
5
+ return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
3
6
  }
4
-
5
7
  export { flatten };
@@ -0,0 +1,17 @@
1
+ const require_internal_is = require("../internal/is.cjs");
2
+ function getArray(value, indiced) {
3
+ if (Array.isArray(value)) return value;
4
+ if (require_internal_is.isPlainObject(value)) {
5
+ if (indiced !== true) return Object.values(value);
6
+ const keys = Object.keys(value);
7
+ const { length } = keys;
8
+ const array = [];
9
+ for (let index = 0; index < length; index += 1) {
10
+ const key = keys[index];
11
+ if (!Number.isNaN(Number(key))) array.push(value[key]);
12
+ }
13
+ return array;
14
+ }
15
+ return [value];
16
+ }
17
+ exports.getArray = getArray;
@@ -0,0 +1,17 @@
1
+ import { isPlainObject } from "../internal/is.js";
2
+ function getArray(value, indiced) {
3
+ if (Array.isArray(value)) return value;
4
+ if (isPlainObject(value)) {
5
+ if (indiced !== true) return Object.values(value);
6
+ const keys = Object.keys(value);
7
+ const { length } = keys;
8
+ const array = [];
9
+ for (let index = 0; index < length; index += 1) {
10
+ const key = keys[index];
11
+ if (!Number.isNaN(Number(key))) array.push(value[key]);
12
+ }
13
+ return array;
14
+ }
15
+ return [value];
16
+ }
17
+ export { getArray };
@@ -1,16 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_group = require('../internal/array/group.cjs');
6
-
1
+ const require_internal_array_group = require("../internal/array/group.cjs");
7
2
  function groupBy(array, key, valueOrArrays, arrays) {
8
- return internal_array_group.groupValues(
9
- array,
10
- key,
11
- valueOrArrays,
12
- key === true || valueOrArrays === true || arrays === true
13
- );
3
+ return require_internal_array_group.groupValues(array, key, valueOrArrays, key === true || valueOrArrays === true || arrays === true);
14
4
  }
15
-
16
5
  exports.groupBy = groupBy;
@@ -1,12 +1,5 @@
1
- import { groupValues } from '../internal/array/group.js';
2
-
1
+ import { groupValues } from "../internal/array/group.js";
3
2
  function groupBy(array, key, valueOrArrays, arrays) {
4
- return groupValues(
5
- array,
6
- key,
7
- valueOrArrays,
8
- key === true || valueOrArrays === true || arrays === true
9
- );
3
+ return groupValues(array, key, valueOrArrays, key === true || valueOrArrays === true || arrays === true);
10
4
  }
11
-
12
5
  export { groupBy };
@@ -1,11 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_find = require('../internal/array/find.cjs');
6
-
1
+ const require_internal_array_find = require("../internal/array/find.cjs");
7
2
  function indexOf(array, ...parameters) {
8
- return internal_array_find.findValue("index", array, parameters);
3
+ return require_internal_array_find.findValue("index", array, parameters);
9
4
  }
10
-
11
5
  exports.indexOf = indexOf;
@@ -1,7 +1,5 @@
1
- import { findValue } from '../internal/array/find.js';
2
-
1
+ import { findValue } from "../internal/array/find.js";
3
2
  function indexOf(array, ...parameters) {
4
- return findValue("index", array, parameters);
3
+ return findValue("index", array, parameters);
5
4
  }
6
-
7
5
  export { indexOf };
@@ -1,41 +1,36 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
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');
8
- const array_count = require('./count.cjs');
9
- const array_exists = require('./exists.cjs');
10
- const array_filter = require('./filter.cjs');
11
- const array_find = require('./find.cjs');
12
- const array_flatten = require('./flatten.cjs');
13
- const array_groupBy = require('./group-by.cjs');
14
- const array_indexOf = require('./index-of.cjs');
15
- const array_insert = require('./insert.cjs');
16
- const array_push = require('./push.cjs');
17
- const array_sort = require('./sort.cjs');
18
- const array_splice = require('./splice.cjs');
19
- const array_toMap = require('./to-map.cjs');
20
- const array_toRecord = require('./to-record.cjs');
21
- const array_unique = require('./unique.cjs');
22
-
23
-
24
-
25
- exports.chunk = internal_array_chunk.chunk;
26
- exports.compact = internal_array_compact.compact;
27
- exports.shuffle = internal_array_shuffle.shuffle;
28
- exports.count = array_count.count;
29
- exports.exists = array_exists.exists;
30
- exports.filter = array_filter.filter;
31
- exports.find = array_find.find;
32
- exports.flatten = array_flatten.flatten;
33
- exports.groupBy = array_groupBy.groupBy;
34
- exports.indexOf = array_indexOf.indexOf;
35
- exports.insert = array_insert.insert;
36
- exports.push = array_push.push;
37
- exports.sort = array_sort.sort;
38
- exports.splice = array_splice.splice;
39
- exports.toMap = array_toMap.toMap;
40
- exports.toRecord = array_toRecord.toRecord;
41
- exports.unique = array_unique.unique;
1
+ const require_internal_array_shuffle = require("../internal/array/shuffle.cjs");
2
+ const require_internal_array_compact = require("../internal/array/compact.cjs");
3
+ const require_internal_array_chunk = require("../internal/array/chunk.cjs");
4
+ const require_array_count = require("./count.cjs");
5
+ const require_array_exists = require("./exists.cjs");
6
+ const require_array_filter = require("./filter.cjs");
7
+ const require_array_find = require("./find.cjs");
8
+ const require_array_flatten = require("./flatten.cjs");
9
+ const require_array_get = require("./get.cjs");
10
+ const require_array_group_by = require("./group-by.cjs");
11
+ const require_array_index_of = require("./index-of.cjs");
12
+ const require_array_insert = require("./insert.cjs");
13
+ const require_array_push = require("./push.cjs");
14
+ const require_array_sort = require("./sort.cjs");
15
+ const require_array_splice = require("./splice.cjs");
16
+ const require_array_to_map = require("./to-map.cjs");
17
+ const require_array_to_record = require("./to-record.cjs");
18
+ const require_array_unique = require("./unique.cjs");
19
+ exports.chunk = require_internal_array_chunk.chunk;
20
+ exports.compact = require_internal_array_compact.compact;
21
+ exports.count = require_array_count.count;
22
+ exports.exists = require_array_exists.exists;
23
+ exports.filter = require_array_filter.filter;
24
+ exports.find = require_array_find.find;
25
+ exports.flatten = require_array_flatten.flatten;
26
+ exports.getArray = require_array_get.getArray;
27
+ exports.groupBy = require_array_group_by.groupBy;
28
+ exports.indexOf = require_array_index_of.indexOf;
29
+ exports.insert = require_array_insert.insert;
30
+ exports.push = require_array_push.push;
31
+ exports.shuffle = require_internal_array_shuffle.shuffle;
32
+ exports.sort = require_array_sort.sort;
33
+ exports.splice = require_array_splice.splice;
34
+ exports.toMap = require_array_to_map.toMap;
35
+ exports.toRecord = require_array_to_record.toRecord;
36
+ exports.unique = require_array_unique.unique;
@@ -1,17 +1,19 @@
1
- export { chunk } from '../internal/array/chunk.js';
2
- export { compact } from '../internal/array/compact.js';
3
- export { shuffle } from '../internal/array/shuffle.js';
4
- export { count } from './count.js';
5
- export { exists } from './exists.js';
6
- export { filter } from './filter.js';
7
- export { find } from './find.js';
8
- export { flatten } from './flatten.js';
9
- export { groupBy } from './group-by.js';
10
- export { indexOf } from './index-of.js';
11
- export { insert } from './insert.js';
12
- export { push } from './push.js';
13
- export { sort } from './sort.js';
14
- export { splice } from './splice.js';
15
- export { toMap } from './to-map.js';
16
- export { toRecord } from './to-record.js';
17
- export { unique } from './unique.js';
1
+ import { shuffle } from "../internal/array/shuffle.js";
2
+ import { compact } from "../internal/array/compact.js";
3
+ import { chunk } from "../internal/array/chunk.js";
4
+ import { count } from "./count.js";
5
+ import { exists } from "./exists.js";
6
+ import { filter } from "./filter.js";
7
+ import { find } from "./find.js";
8
+ import { flatten } from "./flatten.js";
9
+ import { getArray } from "./get.js";
10
+ import { groupBy } from "./group-by.js";
11
+ import { indexOf } from "./index-of.js";
12
+ import { insert } from "./insert.js";
13
+ import { push } from "./push.js";
14
+ import { sort } from "./sort.js";
15
+ import { splice } from "./splice.js";
16
+ import { toMap } from "./to-map.js";
17
+ import { toRecord } from "./to-record.js";
18
+ import { unique } from "./unique.js";
19
+ export { chunk, compact, count, exists, filter, find, flatten, getArray, groupBy, indexOf, insert, push, shuffle, sort, splice, toMap, toRecord, unique };
@@ -1,17 +1,5 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_insert = require('../internal/array/insert.cjs');
6
-
1
+ const require_internal_array_insert = require("../internal/array/insert.cjs");
7
2
  function insert(array, indexOrItems, items) {
8
- return internal_array_insert.insertValues(
9
- "insert",
10
- array,
11
- items == null ? indexOrItems : items,
12
- typeof indexOrItems === "number" ? indexOrItems : array?.length,
13
- 0
14
- );
3
+ return require_internal_array_insert.insertValues("insert", array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
15
4
  }
16
-
17
5
  exports.insert = insert;
@@ -1,13 +1,5 @@
1
- import { insertValues } from '../internal/array/insert.js';
2
-
1
+ import { insertValues } from "../internal/array/insert.js";
3
2
  function insert(array, indexOrItems, items) {
4
- return insertValues(
5
- "insert",
6
- array,
7
- items == null ? indexOrItems : items,
8
- typeof indexOrItems === "number" ? indexOrItems : array?.length,
9
- 0
10
- );
3
+ return insertValues("insert", array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
11
4
  }
12
-
13
5
  export { insert };
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -1 +0,0 @@
1
-
@@ -1,11 +1,10 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_array_insert = require('../internal/array/insert.cjs');
6
-
1
+ const require_internal_array_insert = require("../internal/array/insert.cjs");
2
+ /**
3
+ * - Push values to the end of an array
4
+ * - Returns the new length
5
+ * - _(Uses chunking to avoid call stack size being exceeded)_
6
+ */
7
7
  function push(array, pushed) {
8
- return internal_array_insert.insertValues("push", array, pushed, array.length, 0);
8
+ return require_internal_array_insert.insertValues("push", array, pushed, array.length, 0);
9
9
  }
10
-
11
10
  exports.push = push;
@@ -1,7 +1,10 @@
1
- import { insertValues } from '../internal/array/insert.js';
2
-
1
+ import { insertValues } from "../internal/array/insert.js";
2
+ /**
3
+ * - Push values to the end of an array
4
+ * - Returns the new length
5
+ * - _(Uses chunking to avoid call stack size being exceeded)_
6
+ */
3
7
  function push(array, pushed) {
4
- return insertValues("push", array, pushed, array.length, 0);
8
+ return insertValues("push", array, pushed, array.length, 0);
5
9
  }
6
-
7
10
  export { push };
@@ -1,67 +1,48 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const internal_value_compare = require('../internal/value/compare.cjs');
6
- const internal_is = require('../internal/is.cjs');
7
-
1
+ const require_internal_is = require("../internal/is.cjs");
2
+ require("../is.cjs");
3
+ const require_internal_value_compare = require("../internal/value/compare.cjs");
8
4
  function getSorter(value, modifier) {
9
- const isObject = internal_is.isPlainObject(value);
10
- const sorter = {
11
- identifier: "",
12
- modifier
13
- };
14
- sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
15
- sorter.key = isObject && typeof value.key === "string" ? value.key : typeof value === "string" ? value : void 0;
16
- sorter.callback = sorter.key == null ? isObject && typeof value.value === "function" ? value.value : typeof value === "function" ? value : void 0 : void 0;
17
- if (isObject && typeof value.direction === "string") {
18
- sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
19
- }
20
- if (sorter.key != null || sorter.callback != null) {
21
- sorter.identifier = `${sorter.key ?? sorter.callback}`;
22
- return sorter;
23
- }
5
+ const isObject = require_internal_is.isPlainObject(value);
6
+ const sorter = {
7
+ identifier: "",
8
+ modifier
9
+ };
10
+ sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
11
+ sorter.key = isObject && typeof value.key === "string" ? value.key : typeof value === "string" ? value : void 0;
12
+ sorter.callback = sorter.key == null ? isObject && typeof value.value === "function" ? value.value : typeof value === "function" ? value : void 0 : void 0;
13
+ if (isObject && typeof value.direction === "string") sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
14
+ if (sorter.key != null || sorter.callback != null) {
15
+ sorter.identifier = `${sorter.key ?? sorter.callback}`;
16
+ return sorter;
17
+ }
24
18
  }
25
19
  function sort(array, first, second) {
26
- if (!Array.isArray(array)) {
27
- return [];
28
- }
29
- if (array.length < 2) {
30
- return array;
31
- }
32
- const direction = first === true || second === true ? "desc" : "asc";
33
- const modifier = direction === "asc" ? 1 : -1;
34
- const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter(
35
- (current, index, sorters2) => sorters2.findIndex((next) => next.identifier === current.identifier) === index
36
- );
37
- const { length } = sorters;
38
- if (length === 0) {
39
- return array.sort(
40
- (first2, second2) => internal_value_compare.compare(first2, second2) * modifier
41
- );
42
- }
43
- if (length === 1) {
44
- const sorter = sorters[0];
45
- const { callback, key, modifier: modifier2 } = sorter;
46
- return array.sort((first2, second2) => {
47
- const firstValue = key == null ? callback?.(first2) : first2[key];
48
- const secondValue = key == null ? callback?.(second2) : second2[key];
49
- return (sorter.compare?.(first2, firstValue, second2, secondValue) ?? internal_value_compare.compare(firstValue, secondValue)) * modifier2;
50
- });
51
- }
52
- return array.sort((first2, second2) => {
53
- for (let index = 0; index < length; index += 1) {
54
- const sorter = sorters[index];
55
- const { callback, key, modifier: modifier2 } = sorter;
56
- const firstValue = key == null ? callback?.(first2) : first2[key];
57
- const secondValue = key == null ? callback?.(second2) : second2[key];
58
- const compared = (sorter.compare?.(first2, firstValue, second2, secondValue) ?? internal_value_compare.compare(firstValue, secondValue)) * modifier2;
59
- if (compared !== 0) {
60
- return compared;
61
- }
62
- }
63
- return 0;
64
- });
20
+ if (!Array.isArray(array)) return [];
21
+ if (array.length < 2) return array;
22
+ const direction = first === true || second === true ? "desc" : "asc";
23
+ const modifier = direction === "asc" ? 1 : -1;
24
+ const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter((current, index, sorters$1) => sorters$1.findIndex((next) => next.identifier === current.identifier) === index);
25
+ const { length } = sorters;
26
+ if (length === 0) return array.sort((first$1, second$1) => require_internal_value_compare.compare(first$1, second$1) * modifier);
27
+ if (length === 1) {
28
+ const sorter = sorters[0];
29
+ const { callback, key, modifier: modifier$1 } = sorter;
30
+ return array.sort((first$1, second$1) => {
31
+ const firstValue = key == null ? callback?.(first$1) : first$1[key];
32
+ const secondValue = key == null ? callback?.(second$1) : second$1[key];
33
+ return (sorter.compare?.(first$1, firstValue, second$1, secondValue) ?? require_internal_value_compare.compare(firstValue, secondValue)) * modifier$1;
34
+ });
35
+ }
36
+ return array.sort((first$1, second$1) => {
37
+ for (let index = 0; index < length; index += 1) {
38
+ const sorter = sorters[index];
39
+ const { callback, key, modifier: modifier$1 } = sorter;
40
+ const firstValue = key == null ? callback?.(first$1) : first$1[key];
41
+ const secondValue = key == null ? callback?.(second$1) : second$1[key];
42
+ const compared = (sorter.compare?.(first$1, firstValue, second$1, secondValue) ?? require_internal_value_compare.compare(firstValue, secondValue)) * modifier$1;
43
+ if (compared !== 0) return compared;
44
+ }
45
+ return 0;
46
+ });
65
47
  }
66
-
67
48
  exports.sort = sort;