@oscarpalmer/atoms 0.159.0 → 0.161.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 (148) hide show
  1. package/dist/array/difference.js +2 -0
  2. package/dist/array/exists.js +2 -0
  3. package/dist/array/filter.js +2 -0
  4. package/dist/array/find.js +2 -0
  5. package/dist/array/flatten.js +2 -0
  6. package/dist/array/from.js +2 -0
  7. package/dist/array/get.js +2 -0
  8. package/dist/array/group-by.js +2 -0
  9. package/dist/array/index.js +4 -2
  10. package/dist/array/insert.js +4 -2
  11. package/dist/array/intersection.js +2 -0
  12. package/dist/array/partition.js +2 -0
  13. package/dist/array/position.js +58 -0
  14. package/dist/array/push.js +4 -2
  15. package/dist/array/select.js +2 -0
  16. package/dist/array/slice.js +2 -0
  17. package/dist/array/sort.js +6 -2
  18. package/dist/array/splice.js +4 -2
  19. package/dist/array/swap.js +56 -0
  20. package/dist/array/to-map.js +2 -0
  21. package/dist/array/to-record.js +2 -0
  22. package/dist/array/to-set.js +2 -0
  23. package/dist/array/toggle.js +2 -0
  24. package/dist/array/union.js +2 -0
  25. package/dist/array/unique.js +2 -0
  26. package/dist/array/update.js +2 -0
  27. package/dist/atoms.full.js +259 -125
  28. package/dist/beacon.js +7 -3
  29. package/dist/color/constants.js +35 -33
  30. package/dist/color/index.js +2 -0
  31. package/dist/color/instance.js +3 -0
  32. package/dist/color/misc/alpha.js +2 -0
  33. package/dist/color/misc/get.js +2 -0
  34. package/dist/color/misc/index.js +5 -2
  35. package/dist/color/misc/is.js +2 -0
  36. package/dist/color/misc/state.js +2 -0
  37. package/dist/color/space/hex.js +2 -0
  38. package/dist/color/space/hsl.js +2 -0
  39. package/dist/color/space/rgb.js +2 -0
  40. package/dist/function/assert.js +2 -0
  41. package/dist/function/index.js +2 -0
  42. package/dist/function/memoize.js +4 -1
  43. package/dist/function/once.js +2 -0
  44. package/dist/function/retry.js +2 -0
  45. package/dist/function/work.js +2 -0
  46. package/dist/index.js +4 -2
  47. package/dist/internal/array/callbacks.js +2 -0
  48. package/dist/internal/array/chunk.js +2 -0
  49. package/dist/internal/array/compact.js +2 -0
  50. package/dist/internal/array/find.js +9 -7
  51. package/dist/internal/array/group.js +2 -0
  52. package/dist/{array → internal/array}/index-of.js +3 -1
  53. package/dist/internal/array/insert.js +6 -1
  54. package/dist/internal/array/sets.js +8 -6
  55. package/dist/internal/array/shuffle.js +3 -1
  56. package/dist/internal/array/update.js +2 -0
  57. package/dist/internal/function/misc.js +2 -0
  58. package/dist/internal/function/timer.js +5 -3
  59. package/dist/internal/is.js +2 -0
  60. package/dist/internal/math/aggregate.js +7 -1
  61. package/dist/internal/number.js +3 -1
  62. package/dist/internal/random.js +2 -0
  63. package/dist/internal/result.js +5 -1
  64. package/dist/internal/sized.js +2 -0
  65. package/dist/internal/string.js +2 -0
  66. package/dist/internal/value/compare.js +5 -2
  67. package/dist/internal/value/equal.js +6 -2
  68. package/dist/internal/value/get.js +2 -0
  69. package/dist/internal/value/handlers.js +2 -0
  70. package/dist/internal/value/has.js +2 -0
  71. package/dist/internal/value/misc.js +2 -0
  72. package/dist/internal/value/partial.js +2 -0
  73. package/dist/internal/value/set.js +2 -0
  74. package/dist/is.js +2 -0
  75. package/dist/logger.js +2 -0
  76. package/dist/math.js +4 -2
  77. package/dist/promise/delay.js +4 -2
  78. package/dist/promise/helpers.js +2 -0
  79. package/dist/promise/index.js +5 -3
  80. package/dist/promise/misc.js +4 -2
  81. package/dist/promise/models.js +15 -13
  82. package/dist/promise/timed.js +5 -3
  83. package/dist/query.js +4 -1
  84. package/dist/queue.js +4 -2
  85. package/dist/random.js +2 -0
  86. package/dist/result/index.js +2 -0
  87. package/dist/result/match.js +2 -0
  88. package/dist/result/misc.js +2 -0
  89. package/dist/result/work/flow.js +2 -0
  90. package/dist/result/work/pipe.js +2 -0
  91. package/dist/sized/map.js +2 -0
  92. package/dist/sized/set.js +2 -0
  93. package/dist/string/case.js +22 -12
  94. package/dist/string/index.js +4 -1
  95. package/dist/string/match.js +8 -3
  96. package/dist/string/template.js +2 -0
  97. package/dist/value/clone.js +5 -2
  98. package/dist/value/diff.js +9 -4
  99. package/dist/value/merge.js +2 -0
  100. package/dist/value/omit.js +2 -0
  101. package/dist/value/pick.js +2 -0
  102. package/dist/value/smush.js +3 -1
  103. package/dist/value/unsmush.js +3 -1
  104. package/package.json +3 -3
  105. package/src/array/index.ts +4 -2
  106. package/src/array/insert.ts +2 -2
  107. package/src/array/position.ts +303 -0
  108. package/src/array/push.ts +2 -2
  109. package/src/array/sort.ts +18 -6
  110. package/src/array/splice.ts +2 -2
  111. package/src/array/swap.ts +203 -0
  112. package/src/beacon.ts +7 -3
  113. package/src/color/instance.ts +3 -2
  114. package/src/color/misc/index.ts +5 -3
  115. package/src/function/memoize.ts +3 -1
  116. package/src/internal/array/find.ts +3 -3
  117. package/src/{array → internal/array}/index-of.ts +2 -2
  118. package/src/internal/array/insert.ts +13 -3
  119. package/src/internal/array/sets.ts +3 -3
  120. package/src/internal/array/shuffle.ts +1 -1
  121. package/src/internal/math/aggregate.ts +12 -2
  122. package/src/internal/number.ts +2 -2
  123. package/src/internal/result.ts +9 -1
  124. package/src/internal/value/compare.ts +8 -2
  125. package/src/internal/value/equal.ts +6 -2
  126. package/src/math.ts +11 -4
  127. package/src/promise/delay.ts +2 -2
  128. package/src/promise/index.ts +3 -3
  129. package/src/promise/misc.ts +2 -2
  130. package/src/promise/models.ts +2 -2
  131. package/src/promise/timed.ts +3 -3
  132. package/src/query.ts +3 -1
  133. package/src/queue.ts +3 -3
  134. package/src/string/case.ts +28 -12
  135. package/src/string/index.ts +7 -1
  136. package/src/string/match.ts +9 -3
  137. package/src/value/clone.ts +8 -2
  138. package/src/value/diff.ts +14 -4
  139. package/src/value/smush.ts +1 -1
  140. package/src/value/unsmush.ts +1 -1
  141. package/types/array/index.d.ts +4 -2
  142. package/types/array/position.d.ts +117 -0
  143. package/types/array/sort.d.ts +5 -2
  144. package/types/array/swap.d.ts +77 -0
  145. package/types/{array → internal/array}/index-of.d.ts +1 -1
  146. package/types/internal/array/insert.d.ts +3 -0
  147. package/types/internal/math/aggregate.d.ts +6 -1
  148. package/types/promise/models.d.ts +1 -1
@@ -1,5 +1,7 @@
1
1
  import { COMPARE_SETS_DIFFERENCE, compareSets } from "../internal/array/sets.js";
2
+ //#region src/array/difference.ts
2
3
  function difference(first, second, key) {
3
4
  return compareSets(COMPARE_SETS_DIFFERENCE, first, second, key);
4
5
  }
6
+ //#endregion
5
7
  export { difference };
@@ -1,6 +1,8 @@
1
1
  import { FIND_VALUE_INDEX, findValue } from "../internal/array/find.js";
2
+ //#region src/array/exists.ts
2
3
  function exists(array, ...parameters) {
3
4
  if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
4
5
  return findValue(FIND_VALUE_INDEX, array, parameters) > -1;
5
6
  }
7
+ //#endregion
6
8
  export { exists };
@@ -1,4 +1,5 @@
1
1
  import { findValues } from "../internal/array/find.js";
2
+ //#region src/array/filter.ts
2
3
  function filter(array, ...parameters) {
3
4
  return findValues("all", array, parameters).matched;
4
5
  }
@@ -6,4 +7,5 @@ filter.remove = removeFiltered;
6
7
  function removeFiltered(array, ...parameters) {
7
8
  return findValues("all", array, parameters).notMatched;
8
9
  }
10
+ //#endregion
9
11
  export { filter };
@@ -1,5 +1,7 @@
1
1
  import { FIND_VALUE_VALUE, findValue } from "../internal/array/find.js";
2
+ //#region src/array/find.ts
2
3
  function find(array, ...parameters) {
3
4
  return findValue(FIND_VALUE_VALUE, array, parameters);
4
5
  }
6
+ //#endregion
5
7
  export { find };
@@ -1,3 +1,4 @@
1
+ //#region src/array/flatten.ts
1
2
  /**
2
3
  * Flatten an array _(using native `flat` and maximum depth)_
3
4
  * @param array Array to flatten
@@ -6,4 +7,5 @@
6
7
  function flatten(array) {
7
8
  return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
8
9
  }
10
+ //#endregion
9
11
  export { flatten };
@@ -1,3 +1,4 @@
1
+ //#region src/array/from.ts
1
2
  function range(first, second, third) {
2
3
  const start = typeof second === "number" ? first : 0;
3
4
  const end = typeof second === "number" ? second : first;
@@ -15,4 +16,5 @@ function times(length, value) {
15
16
  for (let index = 0; index < length; index += 1) values.push(isFunction ? value(index) : value ?? index);
16
17
  return values;
17
18
  }
19
+ //#endregion
18
20
  export { range, times };
package/dist/array/get.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
+ //#region src/array/get.ts
2
3
  function getArray(value, indiced) {
3
4
  if (Array.isArray(value)) return value;
4
5
  if (value instanceof Map || value instanceof Set) return [...value.values()];
@@ -13,4 +14,5 @@ function getArray(value, indiced) {
13
14
  }
14
15
  return array;
15
16
  }
17
+ //#endregion
16
18
  export { getArray };
@@ -1,4 +1,5 @@
1
1
  import { groupValues } from "../internal/array/group.js";
2
+ //#region src/array/group-by.ts
2
3
  function groupBy(array, first, second) {
3
4
  return groupValues(array, first, second, false);
4
5
  }
@@ -6,4 +7,5 @@ groupBy.arrays = groupArraysBy;
6
7
  function groupArraysBy(array, first, second) {
7
8
  return groupValues(array, first, second, true);
8
9
  }
10
+ //#endregion
9
11
  export { groupBy };
@@ -5,20 +5,22 @@ import { find } from "./find.js";
5
5
  import { flatten } from "./flatten.js";
6
6
  import { range, times } from "./from.js";
7
7
  import { getArray } from "./get.js";
8
- import { indexOf } from "./index-of.js";
9
8
  import { chunk } from "../internal/array/chunk.js";
10
9
  import { compact } from "../internal/array/compact.js";
10
+ import { indexOf } from "../internal/array/index-of.js";
11
11
  import { shuffle } from "../internal/array/shuffle.js";
12
12
  import { insert } from "./insert.js";
13
13
  import { intersection } from "./intersection.js";
14
14
  import { partition } from "./partition.js";
15
+ import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.js";
15
16
  import { push } from "./push.js";
16
17
  import { select } from "./select.js";
17
18
  import { drop, slice, take } from "./slice.js";
18
19
  import { sort } from "./sort.js";
19
20
  import { splice } from "./splice.js";
21
+ import { swap } from "./swap.js";
20
22
  import { toSet } from "./to-set.js";
21
23
  import { toggle } from "./toggle.js";
22
24
  import { union } from "./union.js";
23
25
  import { update } from "./update.js";
24
- export { chunk, compact, difference, drop, exists, filter, find, flatten, getArray, indexOf, insert, intersection, partition, push, range, select, shuffle, slice, sort, splice, take, times, toSet, toggle, union, update };
26
+ export { chunk, compact, difference, drop, endsWithArray, exists, filter, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, partition, push, range, select, shuffle, slice, sort, splice, startsWithArray, swap, take, times, toSet, toggle, union, update };
@@ -1,5 +1,7 @@
1
- import { insertValues } from "../internal/array/insert.js";
1
+ import { INSERT_TYPE_INSERT, insertValues } from "../internal/array/insert.js";
2
+ //#region src/array/insert.ts
2
3
  function insert(array, indexOrItems, items) {
3
- return insertValues("insert", array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
4
+ return insertValues(INSERT_TYPE_INSERT, array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
4
5
  }
6
+ //#endregion
5
7
  export { insert };
@@ -1,5 +1,7 @@
1
1
  import { COMPARE_SETS_INTERSECTION, compareSets } from "../internal/array/sets.js";
2
+ //#region src/array/intersection.ts
2
3
  function intersection(first, second, key) {
3
4
  return compareSets(COMPARE_SETS_INTERSECTION, first, second, key);
4
5
  }
6
+ //#endregion
5
7
  export { intersection };
@@ -1,6 +1,8 @@
1
1
  import { findValues } from "../internal/array/find.js";
2
+ //#region src/array/partition.ts
2
3
  function partition(array, ...parameters) {
3
4
  const { matched, notMatched } = findValues("all", array, parameters);
4
5
  return [matched, notMatched];
5
6
  }
7
+ //#endregion
6
8
  export { partition };
@@ -0,0 +1,58 @@
1
+ import { getArrayCallback } from "../internal/array/callbacks.js";
2
+ //#region src/array/position.ts
3
+ function endsWithArray(haystack, needle, key) {
4
+ return endings.has(getPosition(haystack, needle, key)[1]);
5
+ }
6
+ function getArrayPosition(haystack, needle, key) {
7
+ return getPosition(haystack, needle, key)[1];
8
+ }
9
+ function getName(start, haystack, needle) {
10
+ if (start === 0) return haystack === needle ? POSITION_SAME : POSITION_START;
11
+ return start + needle === haystack ? POSITION_END : POSITION_INSIDE;
12
+ }
13
+ function getPosition(haystack, needle, key) {
14
+ if (!Array.isArray(haystack) || !Array.isArray(needle)) return invalid;
15
+ const haystackLength = haystack.length;
16
+ const needleLength = needle.length;
17
+ if (haystackLength === 0 || needleLength === 0) return outside;
18
+ if (needleLength > haystackLength) return outside;
19
+ const callback = getArrayCallback(key);
20
+ const limit = haystackLength - needleLength + 1;
21
+ let needleValues = callback == null ? needle : needle.slice();
22
+ if (callback != null) for (let needleIndex = 0; needleIndex < needleLength; needleIndex += 1) needleValues[needleIndex] = callback(needle[needleIndex], needleIndex, needle);
23
+ for (let haystackIndex = 0; haystackIndex < limit; haystackIndex += 1) {
24
+ let haystackItem = haystack[haystackIndex];
25
+ let haystackValue = callback?.(haystackItem, haystackIndex, haystack) ?? haystackItem;
26
+ if (!Object.is(haystackValue, needleValues[0])) continue;
27
+ if (needleLength === 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
28
+ for (let needleIndex = 1; needleIndex < needleLength; needleIndex += 1) {
29
+ haystackItem = haystack[haystackIndex + needleIndex];
30
+ haystackValue = callback?.(haystackItem, haystackIndex + needleIndex, haystack) ?? haystackItem;
31
+ if (!Object.is(haystackValue, needleValues[needleIndex])) break;
32
+ if (needleIndex === needleLength - 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
33
+ }
34
+ }
35
+ return outside;
36
+ }
37
+ function includesArray(haystack, needle, key) {
38
+ return !outsides.has(getPosition(haystack, needle, key)[1]);
39
+ }
40
+ function indexOfArray(haystack, needle, key) {
41
+ return getPosition(haystack, needle, key)[0];
42
+ }
43
+ function startsWithArray(haystack, needle, key) {
44
+ return starts.has(getPosition(haystack, needle, key)[1]);
45
+ }
46
+ var POSITION_END = "end";
47
+ var POSITION_INSIDE = "inside";
48
+ var POSITION_INVALID = "invalid";
49
+ var POSITION_OUTSIDE = "outside";
50
+ var POSITION_SAME = "same";
51
+ var POSITION_START = "start";
52
+ var endings = new Set([POSITION_END, POSITION_SAME]);
53
+ var invalid = [-1, POSITION_INVALID];
54
+ var outside = [-1, POSITION_OUTSIDE];
55
+ var outsides = new Set([POSITION_INVALID, POSITION_OUTSIDE]);
56
+ var starts = new Set([POSITION_START, POSITION_SAME]);
57
+ //#endregion
58
+ export { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray };
@@ -1,4 +1,5 @@
1
- import { insertValues } from "../internal/array/insert.js";
1
+ import { INSERT_TYPE_PUSH, insertValues } from "../internal/array/insert.js";
2
+ //#region src/array/push.ts
2
3
  /**
3
4
  * Push items into an array _(at the end)_
4
5
  * @param array Original array
@@ -6,6 +7,7 @@ import { insertValues } from "../internal/array/insert.js";
6
7
  * @returns New length of the array
7
8
  */
8
9
  function push(array, pushed) {
9
- return insertValues("push", array, pushed, array.length, 0);
10
+ return insertValues(INSERT_TYPE_PUSH, array, pushed, array.length, 0);
10
11
  }
12
+ //#endregion
11
13
  export { push };
@@ -1,5 +1,7 @@
1
1
  import { findValues } from "../internal/array/find.js";
2
+ //#region src/array/select.ts
2
3
  function select(array, ...parameters) {
3
4
  return findValues("all", array, parameters, parameters.pop()).matched;
4
5
  }
6
+ //#endregion
5
7
  export { select };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallbacks } from "../internal/array/callbacks.js";
2
+ //#region src/array/slice.ts
2
3
  function drop(array, first, second) {
3
4
  return extract(EXTRACT_DROP, array, first, second);
4
5
  }
@@ -48,4 +49,5 @@ function take(array, first, second) {
48
49
  }
49
50
  var EXTRACT_DROP = "drop";
50
51
  var EXTRACT_TAKE = "take";
52
+ //#endregion
51
53
  export { drop, slice, take };
@@ -1,5 +1,6 @@
1
1
  import { isPlainObject } from "../internal/is.js";
2
2
  import { compare } from "../internal/value/compare.js";
3
+ //#region src/array/sort.ts
3
4
  function getCallback(value, key, forObject) {
4
5
  if (key != null) return;
5
6
  if (forObject && typeof value.value === "function") return value.value;
@@ -32,7 +33,7 @@ function getSorter(value, modifier) {
32
33
  function sort(array, first, second) {
33
34
  if (!Array.isArray(array)) return [];
34
35
  if (array.length < 2) return array;
35
- const modifier = (first === true || second === true ? "desc" : "asc") === "asc" ? 1 : -1;
36
+ const modifier = (first === true || second === true ? "descending" : "ascending") === "ascending" ? 1 : -1;
36
37
  const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter((current, index, filtered) => filtered.findIndex((next) => next.identifier === current.identifier) === index);
37
38
  const { length } = sorters;
38
39
  if (length === 0) return array.sort((firstItem, secondItem) => compare(firstItem, secondItem) * modifier);
@@ -57,4 +58,7 @@ function sort(array, first, second) {
57
58
  return 0;
58
59
  });
59
60
  }
60
- export { sort };
61
+ var SORT_DIRECTION_ASCENDING = "ascending";
62
+ var SORT_DIRECTION_DESCENDING = "descending";
63
+ //#endregion
64
+ export { SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, sort };
@@ -1,5 +1,7 @@
1
- import { insertValues } from "../internal/array/insert.js";
1
+ import { INSERT_TYPE_SPLICE, insertValues } from "../internal/array/insert.js";
2
+ //#region src/array/splice.ts
2
3
  function splice(array, start, deleteCountOrItems, items) {
3
- return insertValues("splice", array, typeof deleteCountOrItems === "number" ? items : deleteCountOrItems, start, typeof deleteCountOrItems === "number" ? deleteCountOrItems : 0);
4
+ return insertValues(INSERT_TYPE_SPLICE, array, typeof deleteCountOrItems === "number" ? items : deleteCountOrItems, start, typeof deleteCountOrItems === "number" ? deleteCountOrItems : 0);
4
5
  }
6
+ //#endregion
5
7
  export { splice };
@@ -0,0 +1,56 @@
1
+ import { getArrayCallback } from "../internal/array/callbacks.js";
2
+ import { indexOf } from "../internal/array/index-of.js";
3
+ import { indexOfArray } from "./position.js";
4
+ //#region src/array/swap.ts
5
+ function swap(array, first, second, third) {
6
+ if (!Array.isArray(array)) return [];
7
+ if (array.length === 0) return array;
8
+ if (Array.isArray(first) && Array.isArray(second)) return swapArrays(array, first, second, third);
9
+ return swapValues(array, first, second, third);
10
+ }
11
+ swap.indices = swapIndices;
12
+ function swapArrays(array, from, to, key) {
13
+ if (from.length === 0 || to.length === 0) return array;
14
+ if (from.length === 1 && to.length === 1) return swapValues(array, from[0], to[0], key);
15
+ const fromIndex = indexOfArray(array, from, key);
16
+ const toIndex = indexOfArray(array, to, key);
17
+ if (fromIndex === -1 || toIndex === -1) return array;
18
+ const first = fromIndex < toIndex ? from : to;
19
+ const second = fromIndex < toIndex ? to : from;
20
+ const firstIndex = first === from ? fromIndex : toIndex;
21
+ const secondIndex = first === from ? toIndex : fromIndex;
22
+ const firstEnd = firstIndex + first.length - 1;
23
+ if (firstIndex <= secondIndex + second.length - 1 && firstEnd >= secondIndex) return array;
24
+ array.splice(firstIndex, first.length, ...second);
25
+ array.splice(secondIndex, second.length, ...first);
26
+ return array;
27
+ }
28
+ /**
29
+ * Swap two indiced items in an array
30
+ *
31
+ * If either index is out of bounds, the array will be returned unchanged
32
+ * @param array Array of items to swap
33
+ * @param first First index _(can be negative to count from the end)_
34
+ * @param second Second index _(can be negative to count from the end)_
35
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
36
+ */
37
+ function swapIndices(array, first, second) {
38
+ if (!Array.isArray(array) || array.length === 0) return [];
39
+ if (typeof first !== "number" || typeof second !== "number") return array;
40
+ const firstIndex = first < 0 ? array.length + first : first;
41
+ const secondIndex = second < 0 ? array.length + second : second;
42
+ if (firstIndex === secondIndex || firstIndex >= array.length || secondIndex >= array.length) return array;
43
+ const temp = array[firstIndex];
44
+ array[firstIndex] = array[secondIndex];
45
+ array[secondIndex] = temp;
46
+ return array;
47
+ }
48
+ function swapValues(array, from, to, key) {
49
+ const callback = getArrayCallback(key);
50
+ const first = callback == null ? array.indexOf(from) : indexOf(array, callback, callback(from, void 0, []));
51
+ const second = callback == null ? array.indexOf(to) : indexOf(array, callback, callback(to, void 0, []));
52
+ if (first === second || first === -1 || second === -1) return array;
53
+ return swapIndices(array, first, second);
54
+ }
55
+ //#endregion
56
+ export { swap };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallbacks } from "../internal/array/callbacks.js";
2
+ //#region src/array/to-map.ts
2
3
  function getMapValues(array, first, second, arrays) {
3
4
  if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
4
5
  const { length } = array;
@@ -23,4 +24,5 @@ toMap.arrays = toMapArrays;
23
24
  function toMapArrays(array, first, second) {
24
25
  return getMapValues(array, first, second, true);
25
26
  }
27
+ //#endregion
26
28
  export { toMap };
@@ -1,4 +1,5 @@
1
1
  import { groupValues } from "../internal/array/group.js";
2
+ //#region src/array/to-record.ts
2
3
  function toRecord(array, first, second) {
3
4
  return groupValues(array, first, second, false);
4
5
  }
@@ -6,4 +7,5 @@ toRecord.arrays = toRecordArrays;
6
7
  function toRecordArrays(array, first, second) {
7
8
  return groupValues(array, first, second, true);
8
9
  }
10
+ //#endregion
9
11
  export { toRecord };
@@ -1,4 +1,5 @@
1
1
  import { getArrayCallbacks } from "../internal/array/callbacks.js";
2
+ //#region src/array/to-set.ts
2
3
  function toSet(array, value) {
3
4
  if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
4
5
  const callbacks = getArrayCallbacks(void 0, void 0, value);
@@ -8,4 +9,5 @@ function toSet(array, value) {
8
9
  for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
9
10
  return set;
10
11
  }
12
+ //#endregion
11
13
  export { toSet };
@@ -1,5 +1,7 @@
1
1
  import { updateInArray } from "../internal/array/update.js";
2
+ //#region src/array/toggle.ts
2
3
  function toggle(array, values, key) {
3
4
  return updateInArray(array, values, key, false);
4
5
  }
6
+ //#endregion
5
7
  export { toggle };
@@ -1,5 +1,7 @@
1
1
  import { COMPARE_SETS_UNION, compareSets } from "../internal/array/sets.js";
2
+ //#region src/array/union.ts
2
3
  function union(first, second, key) {
3
4
  return compareSets(COMPARE_SETS_UNION, first, second, key);
4
5
  }
6
+ //#endregion
5
7
  export { union };
@@ -1,6 +1,8 @@
1
1
  import { FIND_VALUES_UNIQUE, findValues } from "../internal/array/find.js";
2
+ //#region src/array/unique.ts
2
3
  function unique(array, key) {
3
4
  if (!Array.isArray(array)) return [];
4
5
  return array.length > 1 ? findValues(FIND_VALUES_UNIQUE, array, [key, void 0]).matched : array;
5
6
  }
7
+ //#endregion
6
8
  export { unique };
@@ -1,5 +1,7 @@
1
1
  import { updateInArray } from "../internal/array/update.js";
2
+ //#region src/array/update.ts
2
3
  function update(array, values, key) {
3
4
  return updateInArray(array, values, key, true);
4
5
  }
6
+ //#endregion
5
7
  export { update };