@oscarpalmer/atoms 0.75.0 → 0.76.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 (215) hide show
  1. package/dist/js/array/chunk.cjs +2 -1
  2. package/dist/js/array/chunk.js +2 -1
  3. package/dist/js/array/count.cjs +10 -3
  4. package/dist/js/array/count.js +10 -3
  5. package/dist/js/array/exists.cjs +10 -3
  6. package/dist/js/array/exists.js +10 -3
  7. package/dist/js/array/filter.cjs +10 -3
  8. package/dist/js/array/filter.js +10 -3
  9. package/dist/js/array/find.cjs +10 -3
  10. package/dist/js/array/find.js +10 -3
  11. package/dist/js/array/group-by.cjs +18 -16
  12. package/dist/js/array/group-by.js +18 -16
  13. package/dist/js/array/index-of.cjs +10 -3
  14. package/dist/js/array/index-of.js +10 -3
  15. package/dist/js/array/index.cjs +2 -2
  16. package/dist/js/array/index.js +2 -2
  17. package/dist/js/array/insert.cjs +10 -4
  18. package/dist/js/array/insert.js +10 -4
  19. package/dist/js/array/splice.cjs +4 -4
  20. package/dist/js/array/splice.js +4 -4
  21. package/dist/js/array/to-map.cjs +11 -11
  22. package/dist/js/array/to-map.js +11 -11
  23. package/dist/js/array/to-record.cjs +3 -3
  24. package/dist/js/array/to-record.js +3 -3
  25. package/dist/js/array/unique.cjs +2 -2
  26. package/dist/js/array/unique.js +2 -2
  27. package/dist/js/colour/base.cjs +1 -1
  28. package/dist/js/colour/base.js +1 -1
  29. package/dist/js/colour/hex.cjs +2 -2
  30. package/dist/js/colour/hex.js +2 -2
  31. package/dist/js/colour/hsl.cjs +13 -7
  32. package/dist/js/colour/hsl.js +13 -7
  33. package/dist/js/colour/rgb.cjs +12 -6
  34. package/dist/js/colour/rgb.js +12 -6
  35. package/dist/js/emitter.cjs +8 -5
  36. package/dist/js/emitter.js +8 -5
  37. package/dist/js/function.cjs +6 -6
  38. package/dist/js/function.js +6 -6
  39. package/dist/js/index.cjs +0 -1
  40. package/dist/js/index.js +1 -2
  41. package/dist/js/internal/array/callbacks.cjs +23 -0
  42. package/dist/js/internal/array/callbacks.js +23 -0
  43. package/dist/js/internal/{array-find.cjs → array/find.cjs} +11 -12
  44. package/dist/js/internal/{array-find.js → array/find.js} +11 -12
  45. package/dist/js/logger.cjs +13 -13
  46. package/dist/js/logger.js +13 -13
  47. package/dist/js/query.cjs +0 -3
  48. package/dist/js/query.js +1 -4
  49. package/dist/js/random.cjs +0 -6
  50. package/dist/js/random.js +0 -6
  51. package/dist/js/sized.cjs +1 -1
  52. package/dist/js/sized.js +1 -1
  53. package/dist/js/string/index.cjs +7 -1
  54. package/dist/js/string/index.js +7 -1
  55. package/dist/js/value/compare.cjs +0 -1
  56. package/dist/js/value/compare.js +0 -1
  57. package/dist/js/value/get.cjs +3 -3
  58. package/dist/js/value/get.js +2 -2
  59. package/dist/js/value/set.cjs +4 -4
  60. package/dist/js/value/set.js +2 -2
  61. package/package.json +3 -2
  62. package/src/js/array/chunk.ts +6 -5
  63. package/src/js/array/compact.ts +8 -10
  64. package/src/js/array/count.ts +39 -19
  65. package/src/js/array/exists.ts +40 -16
  66. package/src/js/array/filter.ts +42 -20
  67. package/src/js/array/find.ts +45 -20
  68. package/src/js/array/group-by.ts +158 -27
  69. package/src/js/array/index-of.ts +40 -18
  70. package/src/js/array/index.ts +10 -9
  71. package/src/js/array/insert.ts +28 -14
  72. package/src/js/array/models.ts +18 -15
  73. package/src/js/array/shuffle.ts +3 -3
  74. package/src/js/array/sort.ts +28 -34
  75. package/src/js/array/splice.ts +22 -26
  76. package/src/js/array/to-map.ts +133 -45
  77. package/src/js/array/to-record.ts +137 -39
  78. package/src/js/array/unique.ts +20 -15
  79. package/src/js/colour/base.ts +3 -3
  80. package/src/js/colour/functions.ts +4 -6
  81. package/src/js/colour/hex.ts +5 -5
  82. package/src/js/colour/hsl.ts +18 -12
  83. package/src/js/colour/index.ts +1 -1
  84. package/src/js/colour/is.ts +3 -3
  85. package/src/js/colour/rgb.ts +17 -11
  86. package/src/js/emitter.ts +12 -9
  87. package/src/js/function.ts +12 -12
  88. package/src/js/index.ts +16 -16
  89. package/src/js/internal/array/callbacks.ts +33 -0
  90. package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
  91. package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
  92. package/src/js/is.ts +2 -2
  93. package/src/js/logger.ts +14 -14
  94. package/src/js/math.ts +1 -1
  95. package/src/js/models.ts +5 -5
  96. package/src/js/number.ts +2 -2
  97. package/src/js/query.ts +6 -10
  98. package/src/js/queue.ts +1 -1
  99. package/src/js/random.ts +9 -19
  100. package/src/js/sized.ts +145 -145
  101. package/src/js/string/case.ts +1 -1
  102. package/src/js/string/index.ts +13 -7
  103. package/src/js/string/template.ts +6 -3
  104. package/src/js/value/clone.ts +3 -7
  105. package/src/js/value/compare.ts +3 -5
  106. package/src/js/value/diff.ts +4 -4
  107. package/src/js/value/equal.ts +2 -2
  108. package/src/js/value/get.ts +3 -3
  109. package/src/js/value/index.ts +2 -2
  110. package/src/js/value/merge.ts +3 -3
  111. package/src/js/value/set.ts +3 -4
  112. package/src/js/value/smush.ts +4 -4
  113. package/src/js/value/unsmush.ts +4 -4
  114. package/types/array/chunk.d.cts +2 -2
  115. package/types/array/chunk.d.ts +2 -2
  116. package/types/array/compact.d.cts +4 -4
  117. package/types/array/compact.d.ts +4 -4
  118. package/types/array/count.d.cts +15 -8
  119. package/types/array/count.d.ts +13 -7
  120. package/types/array/exists.d.cts +14 -5
  121. package/types/array/exists.d.ts +12 -4
  122. package/types/array/filter.d.cts +16 -7
  123. package/types/array/filter.d.ts +14 -6
  124. package/types/array/find.d.cts +16 -7
  125. package/types/array/find.d.ts +14 -6
  126. package/types/array/group-by.d.cts +51 -5
  127. package/types/array/group-by.d.ts +49 -5
  128. package/types/array/index-of.d.cts +16 -7
  129. package/types/array/index-of.d.ts +14 -6
  130. package/types/array/index.d.cts +239 -95
  131. package/types/array/index.d.ts +7 -6
  132. package/types/array/insert.d.cts +9 -4
  133. package/types/array/insert.d.ts +10 -5
  134. package/types/array/models.d.cts +14 -11
  135. package/types/array/models.d.ts +14 -12
  136. package/types/array/shuffle.d.cts +2 -2
  137. package/types/array/shuffle.d.ts +2 -2
  138. package/types/array/sort.d.cts +11 -11
  139. package/types/array/sort.d.ts +10 -10
  140. package/types/array/splice.d.cts +4 -4
  141. package/types/array/splice.d.ts +4 -4
  142. package/types/array/to-map.d.cts +44 -20
  143. package/types/array/to-map.d.ts +42 -20
  144. package/types/array/to-record.d.cts +44 -20
  145. package/types/array/to-record.d.ts +42 -20
  146. package/types/array/unique.d.cts +11 -6
  147. package/types/array/unique.d.ts +10 -6
  148. package/types/colour/base.d.cts +28 -16
  149. package/types/colour/base.d.ts +2 -2
  150. package/types/colour/functions.d.cts +28 -16
  151. package/types/colour/functions.d.ts +3 -3
  152. package/types/colour/hex.d.cts +28 -16
  153. package/types/colour/hex.d.ts +4 -4
  154. package/types/colour/hsl.d.cts +28 -16
  155. package/types/colour/hsl.d.ts +16 -10
  156. package/types/colour/index.d.cts +28 -16
  157. package/types/colour/index.d.ts +1 -1
  158. package/types/colour/is.d.cts +28 -16
  159. package/types/colour/is.d.ts +3 -3
  160. package/types/colour/rgb.d.cts +28 -16
  161. package/types/colour/rgb.d.ts +15 -9
  162. package/types/emitter.d.cts +11 -8
  163. package/types/emitter.d.ts +11 -8
  164. package/types/function.d.cts +10 -10
  165. package/types/function.d.ts +11 -11
  166. package/types/index.d.cts +1061 -669
  167. package/types/index.d.ts +16 -16
  168. package/types/internal/array/callbacks.d.cts +11 -0
  169. package/types/internal/array/callbacks.d.ts +2 -0
  170. package/types/internal/array/find.d.cts +7 -0
  171. package/types/internal/array/find.d.ts +3 -0
  172. package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
  173. package/types/is.d.ts +1 -1
  174. package/types/logger.d.cts +13 -13
  175. package/types/logger.d.ts +13 -13
  176. package/types/math.d.cts +1 -1
  177. package/types/math.d.ts +1 -1
  178. package/types/models.d.cts +4 -4
  179. package/types/models.d.ts +1 -4
  180. package/types/number.d.cts +2 -2
  181. package/types/number.d.ts +2 -2
  182. package/types/query.d.cts +2 -2
  183. package/types/query.d.ts +3 -3
  184. package/types/queue.d.cts +1 -1
  185. package/types/queue.d.ts +1 -1
  186. package/types/random.d.cts +8 -12
  187. package/types/random.d.ts +8 -12
  188. package/types/sized.d.cts +6 -6
  189. package/types/sized.d.ts +6 -6
  190. package/types/string/index.d.cts +6 -3
  191. package/types/string/index.d.ts +3 -3
  192. package/types/string/template.d.cts +3 -0
  193. package/types/string/template.d.ts +4 -1
  194. package/types/value/clone.d.cts +4 -2
  195. package/types/value/clone.d.ts +4 -2
  196. package/types/value/get.d.ts +1 -1
  197. package/types/value/index.d.cts +8 -6
  198. package/types/value/index.d.ts +2 -2
  199. package/types/value/merge.d.cts +1 -1
  200. package/types/value/merge.d.ts +2 -2
  201. package/types/value/set.d.ts +1 -1
  202. package/types/value/smush.d.cts +1 -1
  203. package/types/value/smush.d.ts +2 -2
  204. package/types/value/unsmush.d.cts +1 -1
  205. package/types/value/unsmush.d.ts +2 -2
  206. package/dist/js/internal/array-callbacks.cjs +0 -18
  207. package/dist/js/internal/array-callbacks.js +0 -18
  208. package/src/js/internal/array-callbacks.ts +0 -28
  209. package/types/internal/array-callbacks.d.cts +0 -13
  210. package/types/internal/array-callbacks.d.ts +0 -2
  211. package/types/internal/array-find.d.cts +0 -11
  212. package/types/internal/array-find.d.ts +0 -4
  213. /package/dist/js/internal/{value-handle.cjs → value/handle.cjs} +0 -0
  214. /package/dist/js/internal/{value-handle.js → value/handle.js} +0 -0
  215. /package/types/internal/{value-handle.d.cts → value/handle.d.cts} +0 -0
@@ -5,37 +5,37 @@ const colour_functions = require("./functions.cjs");
5
5
  const number = require("../number.cjs");
6
6
  class HSLColour extends colour_base.Colour {
7
7
  /**
8
- * Gets the current hue
8
+ * Get the current hue
9
9
  */
10
10
  get hue() {
11
11
  return +this.state.value.hue;
12
12
  }
13
13
  /**
14
- * Sets the current hue
14
+ * Set the current hue
15
15
  */
16
16
  set hue(value) {
17
17
  this.state.value.hue = number.clamp(value, 0, 360);
18
18
  }
19
19
  /**
20
- * Gets the current lightness
20
+ * Get the current lightness
21
21
  */
22
22
  get lightness() {
23
23
  return +this.state.value.lightness;
24
24
  }
25
25
  /**
26
- * Sets the current lightness
26
+ * Set the current lightness
27
27
  */
28
28
  set lightness(value) {
29
29
  this.state.value.lightness = number.clamp(value, 0, 100);
30
30
  }
31
31
  /**
32
- * Gets the current saturation
32
+ * Get the current saturation
33
33
  */
34
34
  get saturation() {
35
35
  return +this.state.value.saturation;
36
36
  }
37
37
  /**
38
- * Sets the current saturation
38
+ * Set the current saturation
39
39
  */
40
40
  set saturation(value) {
41
41
  this.state.value.saturation = number.clamp(value, 0, 100);
@@ -43,15 +43,21 @@ class HSLColour extends colour_base.Colour {
43
43
  constructor(value) {
44
44
  super("hsl", value, defaults, properties);
45
45
  }
46
+ /**
47
+ * @inheritdoc
48
+ */
46
49
  toHex() {
47
50
  return HSLColour.toRgb(this.state.value).toHex();
48
51
  }
49
52
  /**
50
- * Converts the colour to an RGB-colour
53
+ * Convert the colour to an RGB-colour
51
54
  */
52
55
  toRgb() {
53
56
  return HSLColour.toRgb(this.state.value);
54
57
  }
58
+ /**
59
+ * @inheritdoc
60
+ */
55
61
  toString() {
56
62
  return `hsl(${this.state.value.hue}, ${this.state.value.saturation}%, ${this.state.value.lightness}%)`;
57
63
  }
@@ -3,37 +3,37 @@ import { hslToRgb } from "./functions.js";
3
3
  import { clamp } from "../number.js";
4
4
  class HSLColour extends Colour {
5
5
  /**
6
- * Gets the current hue
6
+ * Get the current hue
7
7
  */
8
8
  get hue() {
9
9
  return +this.state.value.hue;
10
10
  }
11
11
  /**
12
- * Sets the current hue
12
+ * Set the current hue
13
13
  */
14
14
  set hue(value) {
15
15
  this.state.value.hue = clamp(value, 0, 360);
16
16
  }
17
17
  /**
18
- * Gets the current lightness
18
+ * Get the current lightness
19
19
  */
20
20
  get lightness() {
21
21
  return +this.state.value.lightness;
22
22
  }
23
23
  /**
24
- * Sets the current lightness
24
+ * Set the current lightness
25
25
  */
26
26
  set lightness(value) {
27
27
  this.state.value.lightness = clamp(value, 0, 100);
28
28
  }
29
29
  /**
30
- * Gets the current saturation
30
+ * Get the current saturation
31
31
  */
32
32
  get saturation() {
33
33
  return +this.state.value.saturation;
34
34
  }
35
35
  /**
36
- * Sets the current saturation
36
+ * Set the current saturation
37
37
  */
38
38
  set saturation(value) {
39
39
  this.state.value.saturation = clamp(value, 0, 100);
@@ -41,15 +41,21 @@ class HSLColour extends Colour {
41
41
  constructor(value) {
42
42
  super("hsl", value, defaults, properties);
43
43
  }
44
+ /**
45
+ * @inheritdoc
46
+ */
44
47
  toHex() {
45
48
  return HSLColour.toRgb(this.state.value).toHex();
46
49
  }
47
50
  /**
48
- * Converts the colour to an RGB-colour
51
+ * Convert the colour to an RGB-colour
49
52
  */
50
53
  toRgb() {
51
54
  return HSLColour.toRgb(this.state.value);
52
55
  }
56
+ /**
57
+ * @inheritdoc
58
+ */
53
59
  toString() {
54
60
  return `hsl(${this.state.value.hue}, ${this.state.value.saturation}%, ${this.state.value.lightness}%)`;
55
61
  }
@@ -5,37 +5,37 @@ const colour_functions = require("./functions.cjs");
5
5
  const number = require("../number.cjs");
6
6
  class RGBColour extends colour_base.Colour {
7
7
  /**
8
- * Gets the current blue value
8
+ * Get the current blue value
9
9
  */
10
10
  get blue() {
11
11
  return +this.state.value.blue;
12
12
  }
13
13
  /**
14
- * Sets the current blue value
14
+ * Set the current blue value
15
15
  */
16
16
  set blue(value) {
17
17
  this.state.value.blue = number.clamp(value, 0, 255);
18
18
  }
19
19
  /**
20
- * Gets the current green value
20
+ * Get the current green value
21
21
  */
22
22
  get green() {
23
23
  return +this.state.value.green;
24
24
  }
25
25
  /**
26
- * Sets the current green value
26
+ * Set the current green value
27
27
  */
28
28
  set green(value) {
29
29
  this.state.value.green = number.clamp(value, 0, 255);
30
30
  }
31
31
  /**
32
- * Gets the current red value
32
+ * Get the current red value
33
33
  */
34
34
  get red() {
35
35
  return +this.state.value.red;
36
36
  }
37
37
  /**
38
- * Sets the current red value
38
+ * Set the current red value
39
39
  */
40
40
  set red(value) {
41
41
  this.state.value.red = number.clamp(value, 0, 255);
@@ -43,6 +43,9 @@ class RGBColour extends colour_base.Colour {
43
43
  constructor(value) {
44
44
  super("rgb", value, defaults, properties);
45
45
  }
46
+ /**
47
+ * @inheritdoc
48
+ */
46
49
  toHex() {
47
50
  return RGBColour.toHex(this.value);
48
51
  }
@@ -52,6 +55,9 @@ class RGBColour extends colour_base.Colour {
52
55
  toHsl() {
53
56
  return RGBColour.toHsl(this.value);
54
57
  }
58
+ /**
59
+ * @inheritdoc
60
+ */
55
61
  toString() {
56
62
  return `rgb(${this.value.red}, ${this.value.green}, ${this.value.blue})`;
57
63
  }
@@ -3,37 +3,37 @@ import { rgbToHex, rgbToHsl } from "./functions.js";
3
3
  import { clamp } from "../number.js";
4
4
  class RGBColour extends Colour {
5
5
  /**
6
- * Gets the current blue value
6
+ * Get the current blue value
7
7
  */
8
8
  get blue() {
9
9
  return +this.state.value.blue;
10
10
  }
11
11
  /**
12
- * Sets the current blue value
12
+ * Set the current blue value
13
13
  */
14
14
  set blue(value) {
15
15
  this.state.value.blue = clamp(value, 0, 255);
16
16
  }
17
17
  /**
18
- * Gets the current green value
18
+ * Get the current green value
19
19
  */
20
20
  get green() {
21
21
  return +this.state.value.green;
22
22
  }
23
23
  /**
24
- * Sets the current green value
24
+ * Set the current green value
25
25
  */
26
26
  set green(value) {
27
27
  this.state.value.green = clamp(value, 0, 255);
28
28
  }
29
29
  /**
30
- * Gets the current red value
30
+ * Get the current red value
31
31
  */
32
32
  get red() {
33
33
  return +this.state.value.red;
34
34
  }
35
35
  /**
36
- * Sets the current red value
36
+ * Set the current red value
37
37
  */
38
38
  set red(value) {
39
39
  this.state.value.red = clamp(value, 0, 255);
@@ -41,6 +41,9 @@ class RGBColour extends Colour {
41
41
  constructor(value) {
42
42
  super("rgb", value, defaults, properties);
43
43
  }
44
+ /**
45
+ * @inheritdoc
46
+ */
44
47
  toHex() {
45
48
  return RGBColour.toHex(this.value);
46
49
  }
@@ -50,6 +53,9 @@ class RGBColour extends Colour {
50
53
  toHsl() {
51
54
  return RGBColour.toHsl(this.value);
52
55
  }
56
+ /**
57
+ * @inheritdoc
58
+ */
53
59
  toString() {
54
60
  return `rgb(${this.value.red}, ${this.value.green}, ${this.value.blue})`;
55
61
  }
@@ -30,13 +30,13 @@ class Emitter {
30
30
  };
31
31
  }
32
32
  /**
33
- * Destroys the emitter
33
+ * Destroy the emitter
34
34
  */
35
35
  destroy() {
36
36
  finishEmitter(this.state, false);
37
37
  }
38
38
  /**
39
- * Emits a new value _(and optionally finishes the emitter)_
39
+ * Emit a new value _(and optionally finishes the emitter)_
40
40
  */
41
41
  emit(value, finish) {
42
42
  var _a;
@@ -51,7 +51,7 @@ class Emitter {
51
51
  }
52
52
  }
53
53
  /**
54
- * Emits an error _(and optionally finishes the emitter)_
54
+ * Emit an error _(and optionally finishes the emitter)_
55
55
  */
56
56
  error(error, finish) {
57
57
  var _a;
@@ -65,7 +65,7 @@ class Emitter {
65
65
  }
66
66
  }
67
67
  /**
68
- * Finishes the emitter
68
+ * Finish the emitter
69
69
  */
70
70
  finish() {
71
71
  finishEmitter(this.state, true);
@@ -101,13 +101,16 @@ class Subscription {
101
101
  var _a;
102
102
  return this.state.closed || !(((_a = this.state.emitter) == null ? void 0 : _a.active) ?? false);
103
103
  }
104
+ /**
105
+ * Destroy the subscription
106
+ */
104
107
  destroy() {
105
108
  this.unsubscribe();
106
109
  this.state.emitter = void 0;
107
110
  this.state.observers = void 0;
108
111
  }
109
112
  /**
110
- * Unsubscribes from the observable
113
+ * Unsubscribe from its observable
111
114
  */
112
115
  unsubscribe() {
113
116
  var _a;
@@ -28,13 +28,13 @@ class Emitter {
28
28
  };
29
29
  }
30
30
  /**
31
- * Destroys the emitter
31
+ * Destroy the emitter
32
32
  */
33
33
  destroy() {
34
34
  finishEmitter(this.state, false);
35
35
  }
36
36
  /**
37
- * Emits a new value _(and optionally finishes the emitter)_
37
+ * Emit a new value _(and optionally finishes the emitter)_
38
38
  */
39
39
  emit(value, finish) {
40
40
  var _a;
@@ -49,7 +49,7 @@ class Emitter {
49
49
  }
50
50
  }
51
51
  /**
52
- * Emits an error _(and optionally finishes the emitter)_
52
+ * Emit an error _(and optionally finishes the emitter)_
53
53
  */
54
54
  error(error, finish) {
55
55
  var _a;
@@ -63,7 +63,7 @@ class Emitter {
63
63
  }
64
64
  }
65
65
  /**
66
- * Finishes the emitter
66
+ * Finish the emitter
67
67
  */
68
68
  finish() {
69
69
  finishEmitter(this.state, true);
@@ -99,13 +99,16 @@ class Subscription {
99
99
  var _a;
100
100
  return this.state.closed || !(((_a = this.state.emitter) == null ? void 0 : _a.active) ?? false);
101
101
  }
102
+ /**
103
+ * Destroy the subscription
104
+ */
102
105
  destroy() {
103
106
  this.unsubscribe();
104
107
  this.state.emitter = void 0;
105
108
  this.state.observers = void 0;
106
109
  }
107
110
  /**
108
- * Unsubscribes from the observable
111
+ * Unsubscribe from its observable
109
112
  */
110
113
  unsubscribe() {
111
114
  var _a;
@@ -16,21 +16,21 @@ class Memoised {
16
16
  this.state = { cache, getter };
17
17
  }
18
18
  /**
19
- * Clears the cache
19
+ * Clear the cache
20
20
  */
21
21
  clear() {
22
22
  var _a;
23
23
  (_a = this.state.cache) == null ? void 0 : _a.clear();
24
24
  }
25
25
  /**
26
- * Deletes a result from the cache
26
+ * Delete a result from the cache
27
27
  */
28
28
  delete(key) {
29
29
  var _a;
30
30
  return (_a = this.state.cache) == null ? void 0 : _a.delete(key);
31
31
  }
32
32
  /**
33
- * Destroys the instance, clearing its cache and removing its callback
33
+ * Destroy the instance, clearing its cache and removing its callback
34
34
  */
35
35
  destroy() {
36
36
  this.state.cache.clear();
@@ -38,21 +38,21 @@ class Memoised {
38
38
  this.state.getter = noop;
39
39
  }
40
40
  /**
41
- * Retrieves the result from the cache if it exists, or `undefined` otherwise
41
+ * Get a result from the cache if it exists _(or `undefined` otherwise)_
42
42
  */
43
43
  get(key) {
44
44
  var _a;
45
45
  return (_a = this.state.cache) == null ? void 0 : _a.get(key);
46
46
  }
47
47
  /**
48
- * Checks if the cache has a result for a given key
48
+ * Does the result exist?
49
49
  */
50
50
  has(key) {
51
51
  var _a;
52
52
  return ((_a = this.state.cache) == null ? void 0 : _a.has(key)) ?? false;
53
53
  }
54
54
  /**
55
- * Retrieves the result from the cache if it exists, otherwise runs the callback, caches the result, and returns it
55
+ * Get the result from the cache if it exists; otherwise runs the callback, caches the result, and returns it
56
56
  */
57
57
  run(...parameters) {
58
58
  return this.state.getter(...parameters);
@@ -14,21 +14,21 @@ class Memoised {
14
14
  this.state = { cache, getter };
15
15
  }
16
16
  /**
17
- * Clears the cache
17
+ * Clear the cache
18
18
  */
19
19
  clear() {
20
20
  var _a;
21
21
  (_a = this.state.cache) == null ? void 0 : _a.clear();
22
22
  }
23
23
  /**
24
- * Deletes a result from the cache
24
+ * Delete a result from the cache
25
25
  */
26
26
  delete(key) {
27
27
  var _a;
28
28
  return (_a = this.state.cache) == null ? void 0 : _a.delete(key);
29
29
  }
30
30
  /**
31
- * Destroys the instance, clearing its cache and removing its callback
31
+ * Destroy the instance, clearing its cache and removing its callback
32
32
  */
33
33
  destroy() {
34
34
  this.state.cache.clear();
@@ -36,21 +36,21 @@ class Memoised {
36
36
  this.state.getter = noop;
37
37
  }
38
38
  /**
39
- * Retrieves the result from the cache if it exists, or `undefined` otherwise
39
+ * Get a result from the cache if it exists _(or `undefined` otherwise)_
40
40
  */
41
41
  get(key) {
42
42
  var _a;
43
43
  return (_a = this.state.cache) == null ? void 0 : _a.get(key);
44
44
  }
45
45
  /**
46
- * Checks if the cache has a result for a given key
46
+ * Does the result exist?
47
47
  */
48
48
  has(key) {
49
49
  var _a;
50
50
  return ((_a = this.state.cache) == null ? void 0 : _a.has(key)) ?? false;
51
51
  }
52
52
  /**
53
- * Retrieves the result from the cache if it exists, otherwise runs the callback, caches the result, and returns it
53
+ * Get the result from the cache if it exists; otherwise runs the callback, caches the result, and returns it
54
54
  */
55
55
  run(...parameters) {
56
56
  return this.state.getter(...parameters);
package/dist/js/index.cjs CHANGED
@@ -79,7 +79,6 @@ exports.queue = queue.queue;
79
79
  exports.getRandomBoolean = random.getRandomBoolean;
80
80
  exports.getRandomCharacters = random.getRandomCharacters;
81
81
  exports.getRandomColour = random.getRandomColour;
82
- exports.getRandomDate = random.getRandomDate;
83
82
  exports.getRandomFloat = random.getRandomFloat;
84
83
  exports.getRandomHex = random.getRandomHex;
85
84
  exports.getRandomInteger = random.getRandomInteger;
package/dist/js/index.js CHANGED
@@ -8,7 +8,7 @@ import { average, max, min, round, sum } from "./math.js";
8
8
  import { between, clamp, getNumber } from "./number.js";
9
9
  import { fromQuery, toQuery } from "./query.js";
10
10
  import { queue } from "./queue.js";
11
- import { getRandomBoolean, getRandomCharacters, getRandomColour, getRandomDate, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems } from "./random.js";
11
+ import { getRandomBoolean, getRandomCharacters, getRandomColour, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems } from "./random.js";
12
12
  import { SizedMap, SizedSet } from "./sized.js";
13
13
  import { createUuid, getString, join, parse, truncate, words } from "./string/index.js";
14
14
  import "./touch.js";
@@ -77,7 +77,6 @@ export {
77
77
  getRandomBoolean,
78
78
  getRandomCharacters,
79
79
  getRandomColour,
80
- getRandomDate,
81
80
  getRandomFloat,
82
81
  getRandomHex,
83
82
  getRandomInteger,
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function getCallback(value) {
4
+ switch (typeof value) {
5
+ case "function":
6
+ return value;
7
+ case "number":
8
+ case "string":
9
+ return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
10
+ default:
11
+ return;
12
+ }
13
+ }
14
+ function getCallbacks(bool, key, value) {
15
+ if (typeof bool === "function") {
16
+ return { bool };
17
+ }
18
+ return {
19
+ key: getCallback(key),
20
+ value: getCallback(value)
21
+ };
22
+ }
23
+ exports.getCallbacks = getCallbacks;
@@ -0,0 +1,23 @@
1
+ function getCallback(value) {
2
+ switch (typeof value) {
3
+ case "function":
4
+ return value;
5
+ case "number":
6
+ case "string":
7
+ return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
8
+ default:
9
+ return;
10
+ }
11
+ }
12
+ function getCallbacks(bool, key, value) {
13
+ if (typeof bool === "function") {
14
+ return { bool };
15
+ }
16
+ return {
17
+ key: getCallback(key),
18
+ value: getCallback(value)
19
+ };
20
+ }
21
+ export {
22
+ getCallbacks
23
+ };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const internal_arrayCallbacks = require("./array-callbacks.cjs");
4
- function findValue(type, array, value, key) {
3
+ const internal_array_callbacks = require("./callbacks.cjs");
4
+ function findValue(type, array, bool, key, value) {
5
5
  var _a;
6
- const callbacks = internal_arrayCallbacks.getCallbacks(value, key);
6
+ const callbacks = internal_array_callbacks.getCallbacks(bool, key);
7
7
  if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
8
- return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
8
+ return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
9
9
  }
10
10
  if (callbacks.bool != null) {
11
11
  const index = array.findIndex(callbacks.bool);
@@ -20,28 +20,27 @@ function findValue(type, array, value, key) {
20
20
  }
21
21
  return type === "index" ? -1 : void 0;
22
22
  }
23
- function findValues(type, array, value, key) {
23
+ function findValues(type, array, bool, key, value) {
24
24
  var _a;
25
- const callbacks = internal_arrayCallbacks.getCallbacks(value, key);
25
+ const callbacks = internal_array_callbacks.getCallbacks(bool, key);
26
26
  const { length } = array;
27
27
  if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
28
28
  return Array.from(new Set(array));
29
29
  }
30
- if (typeof (callbacks == null ? void 0 : callbacks.bool) === "function") {
30
+ if ((callbacks == null ? void 0 : callbacks.bool) != null) {
31
31
  return array.filter(callbacks.bool);
32
32
  }
33
33
  if (type === "all" && key == null) {
34
34
  return array.filter((item) => item === value);
35
35
  }
36
- const hasCallback = typeof (callbacks == null ? void 0 : callbacks.key) === "function";
37
36
  const result = [];
38
- const values = hasCallback ? [] : result;
37
+ const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
39
38
  for (let index = 0; index < length; index += 1) {
40
39
  const item = array[index];
41
- const itemKey = hasCallback ? (_a = callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array) : item;
42
- if (type === "all" && itemKey === value || type === "unique" && values.indexOf(itemKey) === -1) {
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) {
43
42
  if (values !== result) {
44
- values.push(itemKey);
43
+ values.push(keyed);
45
44
  }
46
45
  result.push(item);
47
46
  }
@@ -1,9 +1,9 @@
1
- import { getCallbacks } from "./array-callbacks.js";
2
- function findValue(type, array, value, key) {
1
+ import { getCallbacks } from "./callbacks.js";
2
+ function findValue(type, array, bool, key, value) {
3
3
  var _a;
4
- const callbacks = getCallbacks(value, key);
4
+ const callbacks = getCallbacks(bool, key);
5
5
  if ((callbacks == null ? void 0 : callbacks.bool) == null && (callbacks == null ? void 0 : callbacks.key) == null) {
6
- return type === "index" ? array.indexOf(value) : array.find((item) => item === value);
6
+ return type === "index" ? array.findIndex((item) => item === value) : array.find((item) => item === value);
7
7
  }
8
8
  if (callbacks.bool != null) {
9
9
  const index = array.findIndex(callbacks.bool);
@@ -18,28 +18,27 @@ function findValue(type, array, value, key) {
18
18
  }
19
19
  return type === "index" ? -1 : void 0;
20
20
  }
21
- function findValues(type, array, value, key) {
21
+ function findValues(type, array, bool, key, value) {
22
22
  var _a;
23
- const callbacks = getCallbacks(value, key);
23
+ const callbacks = getCallbacks(bool, key);
24
24
  const { length } = array;
25
25
  if (type === "unique" && (callbacks == null ? void 0 : callbacks.key) == null && length >= 100) {
26
26
  return Array.from(new Set(array));
27
27
  }
28
- if (typeof (callbacks == null ? void 0 : callbacks.bool) === "function") {
28
+ if ((callbacks == null ? void 0 : callbacks.bool) != null) {
29
29
  return array.filter(callbacks.bool);
30
30
  }
31
31
  if (type === "all" && key == null) {
32
32
  return array.filter((item) => item === value);
33
33
  }
34
- const hasCallback = typeof (callbacks == null ? void 0 : callbacks.key) === "function";
35
34
  const result = [];
36
- const values = hasCallback ? [] : result;
35
+ const values = (callbacks == null ? void 0 : callbacks.key) != null ? [] : result;
37
36
  for (let index = 0; index < length; index += 1) {
38
37
  const item = array[index];
39
- const itemKey = hasCallback ? (_a = callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array) : item;
40
- if (type === "all" && itemKey === value || type === "unique" && values.indexOf(itemKey) === -1) {
38
+ const keyed = ((_a = callbacks == null ? void 0 : callbacks.key) == null ? void 0 : _a.call(callbacks, item, index, array)) ?? item;
39
+ if (type === "all" && keyed === value || type === "unique" && values.indexOf(keyed) === -1) {
41
40
  if (values !== result) {
42
- values.push(itemKey);
41
+ values.push(keyed);
43
42
  }
44
43
  result.push(item);
45
44
  }