@oscarpalmer/atoms 0.78.0 → 0.80.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 (113) hide show
  1. package/dist/array/sort.cjs +5 -10
  2. package/dist/array/sort.js +5 -10
  3. package/dist/colour/base.cjs +27 -2
  4. package/dist/colour/base.js +27 -2
  5. package/dist/colour/functions.cjs +1 -1
  6. package/dist/colour/functions.js +1 -1
  7. package/dist/colour/hsl.cjs +2 -12
  8. package/dist/colour/hsl.js +2 -12
  9. package/dist/colour/index.cjs +5 -0
  10. package/dist/colour/index.js +6 -1
  11. package/dist/colour/rgb.cjs +2 -8
  12. package/dist/colour/rgb.js +2 -8
  13. package/dist/index.cjs +5 -0
  14. package/dist/index.js +5 -0
  15. package/dist/internal/array/find.cjs +6 -7
  16. package/dist/internal/array/find.js +6 -7
  17. package/dist/value/equal.cjs +4 -1
  18. package/dist/value/equal.js +4 -1
  19. package/package.json +15 -8
  20. package/src/array/chunk.ts +1 -1
  21. package/src/array/count.ts +2 -2
  22. package/src/array/exists.ts +2 -2
  23. package/src/array/filter.ts +2 -2
  24. package/src/array/find.ts +2 -2
  25. package/src/array/group-by.ts +2 -2
  26. package/src/array/index-of.ts +2 -2
  27. package/src/array/index.ts +3 -2
  28. package/src/array/insert.ts +2 -2
  29. package/src/array/models.ts +1 -1
  30. package/src/array/shuffle.ts +1 -1
  31. package/src/array/sort.ts +13 -20
  32. package/src/array/splice.ts +1 -1
  33. package/src/array/to-map.ts +2 -2
  34. package/src/array/to-record.ts +60 -60
  35. package/src/array/unique.ts +5 -5
  36. package/src/colour/base.ts +48 -12
  37. package/src/colour/functions.ts +4 -4
  38. package/src/colour/hex.ts +3 -3
  39. package/src/colour/hsl.ts +6 -18
  40. package/src/colour/index.ts +2 -1
  41. package/src/colour/is.ts +4 -7
  42. package/src/colour/rgb.ts +6 -14
  43. package/src/emitter.ts +1 -1
  44. package/src/function.ts +2 -2
  45. package/src/index.ts +16 -16
  46. package/src/internal/array/callbacks.ts +2 -2
  47. package/src/internal/array/find.ts +10 -11
  48. package/src/internal/value/handle.ts +1 -1
  49. package/src/is.ts +2 -2
  50. package/src/logger.ts +1 -1
  51. package/src/query.ts +4 -4
  52. package/src/random.ts +1 -1
  53. package/src/sized.ts +1 -1
  54. package/src/string/case.ts +1 -1
  55. package/src/string/index.ts +2 -1
  56. package/src/string/template.ts +3 -3
  57. package/src/value/clone.ts +3 -3
  58. package/src/value/compare.ts +3 -3
  59. package/src/value/diff.ts +4 -4
  60. package/src/value/equal.ts +6 -3
  61. package/src/value/get.ts +2 -2
  62. package/src/value/index.ts +2 -1
  63. package/src/value/merge.ts +2 -2
  64. package/src/value/set.ts +2 -2
  65. package/src/value/smush.ts +3 -3
  66. package/src/value/unsmush.ts +3 -3
  67. package/types/array/count.d.ts +1 -1
  68. package/types/array/exists.d.ts +1 -1
  69. package/types/array/filter.d.ts +1 -1
  70. package/types/array/find.d.ts +1 -1
  71. package/types/array/group-by.d.ts +1 -1
  72. package/types/array/index-of.d.ts +1 -1
  73. package/types/array/index.d.ts +1 -1
  74. package/types/array/insert.d.ts +1 -1
  75. package/types/array/models.d.ts +1 -1
  76. package/types/array/sort.d.ts +2 -2
  77. package/types/array/to-map.d.ts +1 -1
  78. package/types/array/to-record.d.ts +1 -1
  79. package/types/array/unique.d.ts +1 -1
  80. package/types/colour/base.d.cts +9 -1
  81. package/types/colour/base.d.ts +12 -2
  82. package/types/colour/functions.d.cts +9 -1
  83. package/types/colour/functions.d.ts +3 -3
  84. package/types/colour/hex.d.cts +9 -1
  85. package/types/colour/hex.d.ts +2 -2
  86. package/types/colour/hsl.d.cts +9 -1
  87. package/types/colour/hsl.d.ts +3 -3
  88. package/types/colour/index.d.cts +27 -1
  89. package/types/colour/index.d.ts +2 -1
  90. package/types/colour/is.d.cts +10 -2
  91. package/types/colour/is.d.ts +4 -4
  92. package/types/colour/rgb.d.cts +9 -1
  93. package/types/colour/rgb.d.ts +3 -3
  94. package/types/function.d.ts +1 -1
  95. package/types/index.d.cts +37 -9
  96. package/types/index.d.ts +16 -16
  97. package/types/internal/array/callbacks.d.ts +1 -1
  98. package/types/internal/array/find.d.ts +1 -1
  99. package/types/internal/value/handle.d.ts +1 -1
  100. package/types/is.d.ts +1 -1
  101. package/types/models.d.cts +10 -3
  102. package/types/query.d.ts +1 -1
  103. package/types/string/template.d.ts +1 -1
  104. package/types/value/get.d.cts +10 -3
  105. package/types/value/get.d.ts +1 -1
  106. package/types/value/index.d.cts +10 -3
  107. package/types/value/index.d.ts +1 -1
  108. package/types/value/merge.d.ts +1 -1
  109. package/types/value/set.d.cts +2 -1
  110. package/types/value/set.d.ts +1 -1
  111. package/types/value/smush.d.cts +10 -3
  112. package/types/value/smush.d.ts +1 -1
  113. package/types/value/unsmush.d.ts +1 -1
@@ -6,10 +6,7 @@ function sort(array, first, second) {
6
6
  if (array.length < 2) {
7
7
  return array;
8
8
  }
9
- if (first == null || typeof first === "boolean") {
10
- return first === true ? array.sort((first2, second2) => second2 - first2) : array.sort();
11
- }
12
- const direction = second === true ? "desc" : "asc";
9
+ const direction = first === true || second === true ? "desc" : "asc";
13
10
  const keys = (Array.isArray(first) ? first : [first]).map((key) => {
14
11
  const returned = {
15
12
  direction,
@@ -27,7 +24,9 @@ function sort(array, first, second) {
27
24
  }).filter((key) => typeof key.callback === "function");
28
25
  const { length } = keys;
29
26
  if (length === 0) {
30
- return direction === "asc" ? array.sort() : array.sort((first2, second2) => second2 - first2);
27
+ return array.sort(
28
+ (first2, second2) => value_compare.compare(first2, second2) * (direction === "asc" ? 1 : -1)
29
+ );
31
30
  }
32
31
  if (length === 1) {
33
32
  return array.sort(
@@ -37,11 +36,7 @@ function sort(array, first, second) {
37
36
  const sorted = array.sort((first2, second2) => {
38
37
  for (let index = 0; index < length; index += 1) {
39
38
  const { callback, direction: direction2 } = keys[index];
40
- const descending = direction2 === "desc";
41
- const compared = value_compare.compare(
42
- callback(descending ? second2 : first2),
43
- callback(descending ? first2 : second2)
44
- );
39
+ const compared = value_compare.compare(callback(first2), callback(second2)) * (direction2 === "asc" ? 1 : -1);
45
40
  if (compared !== 0) {
46
41
  return compared;
47
42
  }
@@ -4,10 +4,7 @@ function sort(array, first, second) {
4
4
  if (array.length < 2) {
5
5
  return array;
6
6
  }
7
- if (first == null || typeof first === "boolean") {
8
- return first === true ? array.sort((first2, second2) => second2 - first2) : array.sort();
9
- }
10
- const direction = second === true ? "desc" : "asc";
7
+ const direction = first === true || second === true ? "desc" : "asc";
11
8
  const keys = (Array.isArray(first) ? first : [first]).map((key) => {
12
9
  const returned = {
13
10
  direction,
@@ -25,7 +22,9 @@ function sort(array, first, second) {
25
22
  }).filter((key) => typeof key.callback === "function");
26
23
  const { length } = keys;
27
24
  if (length === 0) {
28
- return direction === "asc" ? array.sort() : array.sort((first2, second2) => second2 - first2);
25
+ return array.sort(
26
+ (first2, second2) => compare(first2, second2) * (direction === "asc" ? 1 : -1)
27
+ );
29
28
  }
30
29
  if (length === 1) {
31
30
  return array.sort(
@@ -35,11 +34,7 @@ function sort(array, first, second) {
35
34
  const sorted = array.sort((first2, second2) => {
36
35
  for (let index = 0; index < length; index += 1) {
37
36
  const { callback, direction: direction2 } = keys[index];
38
- const descending = direction2 === "desc";
39
- const compared = compare(
40
- callback(descending ? second2 : first2),
41
- callback(descending ? first2 : second2)
42
- );
37
+ const compared = compare(callback(first2), callback(second2)) * (direction2 === "asc" ? 1 : -1);
43
38
  if (compared !== 0) {
44
39
  return compared;
45
40
  }
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const colour_is = require("./is.cjs");
4
+ const defaults = {
5
+ hsl: {
6
+ hue: 0,
7
+ lightness: 0,
8
+ saturation: 0
9
+ },
10
+ rgb: {
11
+ blue: 0,
12
+ green: 0,
13
+ red: 0
14
+ }
15
+ };
16
+ const properties = {
17
+ hsl: ["hue", "lightness", "saturation"],
18
+ rgb: ["blue", "green", "red"]
19
+ };
20
+ function getValue(value, type) {
21
+ return colour_is.isColourValue(value, properties[type]) ? { ...value } : { ...defaults[type] };
22
+ }
4
23
  class Colour {
5
24
  /**
6
25
  * Get the current value of the colour
@@ -8,10 +27,16 @@ class Colour {
8
27
  get value() {
9
28
  return { ...this.state.value };
10
29
  }
11
- constructor(type, value, defaults, properties) {
30
+ /**
31
+ * Set the current value of the colour
32
+ */
33
+ set value(value) {
34
+ this.state.value = getValue(value, this.$colour);
35
+ }
36
+ constructor(type, value) {
12
37
  this.$colour = type;
13
38
  this.state = {
14
- value: colour_is.isColourValue(value, properties) ? { ...value } : { ...defaults }
39
+ value: getValue(value, type)
15
40
  };
16
41
  }
17
42
  }
@@ -1,4 +1,23 @@
1
1
  import { isColourValue } from "./is.js";
2
+ const defaults = {
3
+ hsl: {
4
+ hue: 0,
5
+ lightness: 0,
6
+ saturation: 0
7
+ },
8
+ rgb: {
9
+ blue: 0,
10
+ green: 0,
11
+ red: 0
12
+ }
13
+ };
14
+ const properties = {
15
+ hsl: ["hue", "lightness", "saturation"],
16
+ rgb: ["blue", "green", "red"]
17
+ };
18
+ function getValue(value, type) {
19
+ return isColourValue(value, properties[type]) ? { ...value } : { ...defaults[type] };
20
+ }
2
21
  class Colour {
3
22
  /**
4
23
  * Get the current value of the colour
@@ -6,10 +25,16 @@ class Colour {
6
25
  get value() {
7
26
  return { ...this.state.value };
8
27
  }
9
- constructor(type, value, defaults, properties) {
28
+ /**
29
+ * Set the current value of the colour
30
+ */
31
+ set value(value) {
32
+ this.state.value = getValue(value, this.$colour);
33
+ }
34
+ constructor(type, value) {
10
35
  this.$colour = type;
11
36
  this.state = {
12
- value: isColourValue(value, properties) ? { ...value } : { ...defaults }
37
+ value: getValue(value, type)
13
38
  };
14
39
  }
15
40
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const number = require("../number.cjs");
3
4
  const colour_hex = require("./hex.cjs");
4
5
  const colour_hsl = require("./hsl.cjs");
5
6
  const colour_rgb = require("./rgb.cjs");
6
- const number = require("../number.cjs");
7
7
  const anyPattern = /^#*([a-f0-9]{3}){1,2}$/i;
8
8
  const groupedPattern = /^#*([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
9
9
  function getNormalisedHex(value) {
@@ -1,7 +1,7 @@
1
+ import { clamp } from "../number.js";
1
2
  import { HexColour } from "./hex.js";
2
3
  import { HSLColour } from "./hsl.js";
3
4
  import { RGBColour } from "./rgb.js";
4
- import { clamp } from "../number.js";
5
5
  const anyPattern = /^#*([a-f0-9]{3}){1,2}$/i;
6
6
  const groupedPattern = /^#*([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
7
7
  function getNormalisedHex(value) {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const number = require("../number.cjs");
3
4
  const colour_base = require("./base.cjs");
4
5
  const colour_functions = require("./functions.cjs");
5
- const number = require("../number.cjs");
6
6
  class HSLColour extends colour_base.Colour {
7
7
  /**
8
8
  * Get the current hue
@@ -41,7 +41,7 @@ class HSLColour extends colour_base.Colour {
41
41
  this.state.value.saturation = number.clamp(value, 0, 100);
42
42
  }
43
43
  constructor(value) {
44
- super("hsl", value, defaults, properties);
44
+ super("hsl", value);
45
45
  }
46
46
  /**
47
47
  * @inheritdoc
@@ -68,16 +68,6 @@ class HSLColour extends colour_base.Colour {
68
68
  return colour_functions.hslToRgb(value);
69
69
  }
70
70
  }
71
- const defaults = {
72
- hue: 0,
73
- lightness: 0,
74
- saturation: 0
75
- };
76
- const properties = [
77
- "hue",
78
- "lightness",
79
- "saturation"
80
- ];
81
71
  function getHSLColour(value) {
82
72
  return new HSLColour(value);
83
73
  }
@@ -1,6 +1,6 @@
1
+ import { clamp } from "../number.js";
1
2
  import { Colour } from "./base.js";
2
3
  import { hslToRgb } from "./functions.js";
3
- import { clamp } from "../number.js";
4
4
  class HSLColour extends Colour {
5
5
  /**
6
6
  * Get the current hue
@@ -39,7 +39,7 @@ class HSLColour extends Colour {
39
39
  this.state.value.saturation = clamp(value, 0, 100);
40
40
  }
41
41
  constructor(value) {
42
- super("hsl", value, defaults, properties);
42
+ super("hsl", value);
43
43
  }
44
44
  /**
45
45
  * @inheritdoc
@@ -66,16 +66,6 @@ class HSLColour extends Colour {
66
66
  return hslToRgb(value);
67
67
  }
68
68
  }
69
- const defaults = {
70
- hue: 0,
71
- lightness: 0,
72
- saturation: 0
73
- };
74
- const properties = [
75
- "hue",
76
- "lightness",
77
- "saturation"
78
- ];
79
69
  function getHSLColour(value) {
80
70
  return new HSLColour(value);
81
71
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const colour_functions = require("./functions.cjs");
3
4
  const colour_hex = require("./hex.cjs");
4
5
  const colour_hsl = require("./hsl.cjs");
5
6
  const colour_is = require("./is.cjs");
@@ -16,6 +17,10 @@ function getForegroundColour(value) {
16
17
  const luminance = 0.2126 * values[2] + 0.7152 * values[1] + 0.0722 * values[0];
17
18
  return luminance > 0.625 ? "black" : "white";
18
19
  }
20
+ exports.hexToRgb = colour_functions.hexToRgb;
21
+ exports.hslToRgb = colour_functions.hslToRgb;
22
+ exports.rgbToHex = colour_functions.rgbToHex;
23
+ exports.rgbToHsl = colour_functions.rgbToHsl;
19
24
  exports.HexColour = colour_hex.HexColour;
20
25
  exports.getHexColour = colour_hex.getHexColour;
21
26
  exports.HSLColour = colour_hsl.HSLColour;
@@ -1,3 +1,4 @@
1
+ import { hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from "./functions.js";
1
2
  import { HexColour, getHexColour } from "./hex.js";
2
3
  import { HSLColour, getHSLColour } from "./hsl.js";
3
4
  import { isColour, isHSLColour, isHexColour, isRGBColour } from "./is.js";
@@ -22,8 +23,12 @@ export {
22
23
  getHSLColour,
23
24
  getHexColour,
24
25
  getRGBColour,
26
+ hexToRgb,
27
+ hslToRgb,
25
28
  isColour,
26
29
  isHSLColour,
27
30
  isHexColour,
28
- isRGBColour
31
+ isRGBColour,
32
+ rgbToHex,
33
+ rgbToHsl
29
34
  };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const number = require("../number.cjs");
3
4
  const colour_base = require("./base.cjs");
4
5
  const colour_functions = require("./functions.cjs");
5
- const number = require("../number.cjs");
6
6
  class RGBColour extends colour_base.Colour {
7
7
  /**
8
8
  * Get the current blue value
@@ -41,7 +41,7 @@ class RGBColour extends colour_base.Colour {
41
41
  this.state.value.red = number.clamp(value, 0, 255);
42
42
  }
43
43
  constructor(value) {
44
- super("rgb", value, defaults, properties);
44
+ super("rgb", value);
45
45
  }
46
46
  /**
47
47
  * @inheritdoc
@@ -74,12 +74,6 @@ class RGBColour extends colour_base.Colour {
74
74
  return colour_functions.rgbToHsl(rgb);
75
75
  }
76
76
  }
77
- const defaults = {
78
- blue: 0,
79
- green: 0,
80
- red: 0
81
- };
82
- const properties = ["blue", "green", "red"];
83
77
  function getRGBColour(value) {
84
78
  return new RGBColour(value);
85
79
  }
@@ -1,6 +1,6 @@
1
+ import { clamp } from "../number.js";
1
2
  import { Colour } from "./base.js";
2
3
  import { rgbToHex, rgbToHsl } from "./functions.js";
3
- import { clamp } from "../number.js";
4
4
  class RGBColour extends Colour {
5
5
  /**
6
6
  * Get the current blue value
@@ -39,7 +39,7 @@ class RGBColour extends Colour {
39
39
  this.state.value.red = clamp(value, 0, 255);
40
40
  }
41
41
  constructor(value) {
42
- super("rgb", value, defaults, properties);
42
+ super("rgb", value);
43
43
  }
44
44
  /**
45
45
  * @inheritdoc
@@ -72,12 +72,6 @@ class RGBColour extends Colour {
72
72
  return rgbToHsl(rgb);
73
73
  }
74
74
  }
75
- const defaults = {
76
- blue: 0,
77
- green: 0,
78
- red: 0
79
- };
80
- const properties = ["blue", "green", "red"];
81
75
  function getRGBColour(value) {
82
76
  return new RGBColour(value);
83
77
  }
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ const array_splice = require("./array/splice.cjs");
30
30
  const array_toMap = require("./array/to-map.cjs");
31
31
  const array_toRecord = require("./array/to-record.cjs");
32
32
  const array_unique = require("./array/unique.cjs");
33
+ const colour_functions = require("./colour/functions.cjs");
33
34
  const colour_hex = require("./colour/hex.cjs");
34
35
  const colour_hsl = require("./colour/hsl.cjs");
35
36
  const colour_is = require("./colour/is.cjs");
@@ -108,6 +109,10 @@ exports.splice = array_splice.splice;
108
109
  exports.toMap = array_toMap.toMap;
109
110
  exports.toRecord = array_toRecord.toRecord;
110
111
  exports.unique = array_unique.unique;
112
+ exports.hexToRgb = colour_functions.hexToRgb;
113
+ exports.hslToRgb = colour_functions.hslToRgb;
114
+ exports.rgbToHex = colour_functions.rgbToHex;
115
+ exports.rgbToHsl = colour_functions.rgbToHsl;
111
116
  exports.HexColour = colour_hex.HexColour;
112
117
  exports.getHexColour = colour_hex.getHexColour;
113
118
  exports.HSLColour = colour_hsl.HSLColour;
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ import { splice } from "./array/splice.js";
28
28
  import { toMap } from "./array/to-map.js";
29
29
  import { toRecord } from "./array/to-record.js";
30
30
  import { unique } from "./array/unique.js";
31
+ import { hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from "./colour/functions.js";
31
32
  import { HexColour, getHexColour } from "./colour/hex.js";
32
33
  import { HSLColour, getHSLColour } from "./colour/hsl.js";
33
34
  import { isColour, isHSLColour, isHexColour, isRGBColour } from "./colour/is.js";
@@ -85,6 +86,8 @@ export {
85
86
  getString,
86
87
  getValue,
87
88
  groupBy,
89
+ hexToRgb,
90
+ hslToRgb,
88
91
  indexOf,
89
92
  insert,
90
93
  isArrayOrPlainObject,
@@ -115,6 +118,8 @@ export {
115
118
  pascalCase,
116
119
  push,
117
120
  queue,
121
+ rgbToHex,
122
+ rgbToHsl,
118
123
  round,
119
124
  setValue,
120
125
  shuffle,
@@ -6,7 +6,7 @@ function findValue(type, array, parameters) {
6
6
  const { bool, key, value } = getParameters(parameters);
7
7
  const callbacks = internal_array_callbacks.getCallbacks(bool, key);
8
8
  if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
9
- return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
9
+ return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
10
10
  }
11
11
  if (callbacks.bool != null) {
12
12
  const index = array.findIndex(callbacks.bool);
@@ -35,18 +35,17 @@ function findValues(type, array, parameters) {
35
35
  if (type === "all" && key == null) {
36
36
  return array.filter((item) => item === value);
37
37
  }
38
+ const keys = /* @__PURE__ */ new Set();
38
39
  const result = [];
39
- const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
40
40
  for (let index = 0; index < length; index += 1) {
41
41
  const item = array[index];
42
- const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
43
- if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
44
- if (values !== result) {
45
- values.push(keyed);
46
- }
42
+ const key2 = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
43
+ if (type === "all" && key2 === value || type === "unique" && !keys.has(key2)) {
44
+ keys.add(key2);
47
45
  result.push(item);
48
46
  }
49
47
  }
48
+ keys.clear();
50
49
  return result;
51
50
  }
52
51
  function getParameters(original) {
@@ -4,7 +4,7 @@ function findValue(type, array, parameters) {
4
4
  const { bool, key, value } = getParameters(parameters);
5
5
  const callbacks = getCallbacks(bool, key);
6
6
  if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
7
- return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
7
+ return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
8
8
  }
9
9
  if (callbacks.bool != null) {
10
10
  const index = array.findIndex(callbacks.bool);
@@ -33,18 +33,17 @@ function findValues(type, array, parameters) {
33
33
  if (type === "all" && key == null) {
34
34
  return array.filter((item) => item === value);
35
35
  }
36
+ const keys = /* @__PURE__ */ new Set();
36
37
  const result = [];
37
- const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
38
38
  for (let index = 0; index < length; index += 1) {
39
39
  const item = array[index];
40
- const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
41
- if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
42
- if (values !== result) {
43
- values.push(keyed);
44
- }
40
+ const key2 = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
41
+ if (type === "all" && key2 === value || type === "unique" && !keys.has(key2)) {
42
+ keys.add(key2);
45
43
  result.push(item);
46
44
  }
47
45
  }
46
+ keys.clear();
48
47
  return result;
49
48
  }
50
49
  function getParameters(original) {
@@ -26,7 +26,10 @@ function equal(first, second, ignoreCase) {
26
26
  return equalSet(first, second);
27
27
  case (Array.isArray(first) && Array.isArray(second)):
28
28
  case (is.isPlainObject(first) && is.isPlainObject(second)):
29
- return equalObject(first, second);
29
+ return equalObject(
30
+ first,
31
+ second
32
+ );
30
33
  case (typeof first === "string" && ignoreCase === true):
31
34
  return Object.is(first.toLowerCase(), second.toLowerCase());
32
35
  default:
@@ -24,7 +24,10 @@ function equal(first, second, ignoreCase) {
24
24
  return equalSet(first, second);
25
25
  case (Array.isArray(first) && Array.isArray(second)):
26
26
  case (isPlainObject(first) && isPlainObject(second)):
27
- return equalObject(first, second);
27
+ return equalObject(
28
+ first,
29
+ second
30
+ );
28
31
  case (typeof first === "string" && ignoreCase === true):
29
32
  return Object.is(first.toLowerCase(), second.toLowerCase());
30
33
  default:
package/package.json CHANGED
@@ -4,18 +4,18 @@
4
4
  "url": "https://oscarpalmer.se"
5
5
  },
6
6
  "dependencies": {
7
- "type-fest": "^4.26"
7
+ "type-fest": "^4.30"
8
8
  },
9
9
  "description": "Atomic utilities for making your JavaScript better.",
10
10
  "devDependencies": {
11
11
  "@biomejs/biome": "^1.9",
12
- "@types/node": "^22.8",
12
+ "@types/node": "^22.10",
13
13
  "@vitest/coverage-istanbul": "^2.1",
14
14
  "dts-bundle-generator": "^9.5",
15
15
  "glob": "^11",
16
- "happy-dom": "^15.7",
17
- "typescript": "^5.6",
18
- "vite": "^5.4",
16
+ "happy-dom": "^15.11",
17
+ "typescript": "^5.7",
18
+ "vite": "^6",
19
19
  "vitest": "^2.1"
20
20
  },
21
21
  "exports": {
@@ -179,8 +179,15 @@
179
179
  }
180
180
  }
181
181
  },
182
- "files": ["dist", "src", "types"],
183
- "keywords": ["helper", "utility"],
182
+ "files": [
183
+ "dist",
184
+ "src",
185
+ "types"
186
+ ],
187
+ "keywords": [
188
+ "helper",
189
+ "utility"
190
+ ],
184
191
  "license": "MIT",
185
192
  "main": "./dist/index.cjs",
186
193
  "module": "./dist/index.js",
@@ -198,5 +205,5 @@
198
205
  },
199
206
  "type": "module",
200
207
  "types": "./types/index.d.cts",
201
- "version": "0.78.0"
208
+ "version": "0.80.0"
202
209
  }
@@ -1,4 +1,4 @@
1
- import {clamp} from '~/number';
1
+ import {clamp} from '../number';
2
2
 
3
3
  /**
4
4
  * Chunk an array _(into smaller arrays of a specified size)_
@@ -1,5 +1,5 @@
1
- import {findValues} from '~/internal/array/find';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {findValues} from '../internal/array/find';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Get the number of items _(count)_ that match the given value
@@ -1,5 +1,5 @@
1
- import {findValue} from '~/internal/array/find';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {findValue} from '../internal/array/find';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Does the value exist in array?
@@ -1,5 +1,5 @@
1
- import {findValues} from '~/internal/array/find';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {findValues} from '../internal/array/find';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Get a filtered array of items matching `value`
package/src/array/find.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {findValue} from '~/internal/array/find';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {findValue} from '../internal/array/find';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Get the first item matching `value` _(or `undefined` if no match is found)_
@@ -1,6 +1,6 @@
1
1
  import type {Simplify} from 'type-fest';
2
- import {getCallbacks} from '~/internal/array/callbacks';
3
- import type {Key, KeyedValue, PlainObject} from '~/models';
2
+ import {getCallbacks} from '../internal/array/callbacks';
3
+ import type {Key, KeyedValue, PlainObject} from '../models';
4
4
 
5
5
  /**
6
6
  * Create a record from an array of items using a specific key
@@ -1,5 +1,5 @@
1
- import {findValue} from '~/internal/array/find';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {findValue} from '../internal/array/find';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Get the index for the first item matching `value` _(or `-1` if no match is found)_
@@ -1,5 +1,5 @@
1
- import {insertValues} from '~/array/insert';
2
- import type {NestedArrayType} from '~/models';
1
+ import {insertValues} from '../array/insert';
2
+ import type {NestedArrayType} from '../models';
3
3
 
4
4
  /**
5
5
  * Flatten an array _(using native `flat` and maximum depth)_
@@ -32,3 +32,4 @@ export * from './splice';
32
32
  export * from './to-map';
33
33
  export * from './to-record';
34
34
  export * from './unique';
35
+
@@ -1,5 +1,5 @@
1
- import {chunk} from '~/array/chunk';
2
- import type {InsertType} from '~/array/models';
1
+ import {chunk} from './chunk';
2
+ import type {InsertType} from './models';
3
3
 
4
4
  /**
5
5
  * - Insert values into an array _(at the end)_
@@ -1,4 +1,4 @@
1
- import type {GenericCallback, Key} from '~/models';
1
+ import type {GenericCallback, Key} from '../models';
2
2
 
3
3
  export type Callbacks = {
4
4
  bool?: GenericCallback;
@@ -1,4 +1,4 @@
1
- import {getRandomInteger} from '~/random';
1
+ import {getRandomInteger} from '../random';
2
2
 
3
3
  /**
4
4
  * Shuffle an array