@oscarpalmer/atoms 0.78.0 → 0.79.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 (97) hide show
  1. package/dist/array/sort.cjs +4 -5
  2. package/dist/array/sort.js +4 -5
  3. package/dist/colour/functions.cjs +1 -1
  4. package/dist/colour/functions.js +1 -1
  5. package/dist/colour/hsl.cjs +1 -1
  6. package/dist/colour/hsl.js +1 -1
  7. package/dist/colour/rgb.cjs +1 -1
  8. package/dist/colour/rgb.js +1 -1
  9. package/dist/value/equal.cjs +4 -1
  10. package/dist/value/equal.js +4 -1
  11. package/package.json +12 -5
  12. package/src/array/chunk.ts +1 -1
  13. package/src/array/count.ts +2 -2
  14. package/src/array/exists.ts +2 -2
  15. package/src/array/filter.ts +2 -2
  16. package/src/array/find.ts +2 -2
  17. package/src/array/group-by.ts +2 -2
  18. package/src/array/index-of.ts +2 -2
  19. package/src/array/index.ts +3 -2
  20. package/src/array/insert.ts +2 -2
  21. package/src/array/models.ts +1 -1
  22. package/src/array/shuffle.ts +1 -1
  23. package/src/array/sort.ts +10 -14
  24. package/src/array/splice.ts +1 -1
  25. package/src/array/to-map.ts +2 -2
  26. package/src/array/to-record.ts +60 -60
  27. package/src/array/unique.ts +5 -5
  28. package/src/colour/base.ts +2 -2
  29. package/src/colour/functions.ts +4 -4
  30. package/src/colour/hex.ts +3 -3
  31. package/src/colour/hsl.ts +5 -5
  32. package/src/colour/index.ts +1 -1
  33. package/src/colour/is.ts +3 -3
  34. package/src/colour/rgb.ts +5 -5
  35. package/src/emitter.ts +1 -1
  36. package/src/function.ts +2 -2
  37. package/src/index.ts +16 -16
  38. package/src/internal/array/callbacks.ts +2 -2
  39. package/src/internal/array/find.ts +2 -2
  40. package/src/internal/value/handle.ts +1 -1
  41. package/src/is.ts +2 -2
  42. package/src/logger.ts +1 -1
  43. package/src/query.ts +4 -4
  44. package/src/random.ts +1 -1
  45. package/src/sized.ts +1 -1
  46. package/src/string/case.ts +1 -1
  47. package/src/string/index.ts +2 -1
  48. package/src/string/template.ts +3 -3
  49. package/src/value/clone.ts +3 -3
  50. package/src/value/compare.ts +3 -3
  51. package/src/value/diff.ts +4 -4
  52. package/src/value/equal.ts +6 -3
  53. package/src/value/get.ts +2 -2
  54. package/src/value/index.ts +2 -1
  55. package/src/value/merge.ts +2 -2
  56. package/src/value/set.ts +2 -2
  57. package/src/value/smush.ts +3 -3
  58. package/src/value/unsmush.ts +3 -3
  59. package/types/array/count.d.ts +1 -1
  60. package/types/array/exists.d.ts +1 -1
  61. package/types/array/filter.d.ts +1 -1
  62. package/types/array/find.d.ts +1 -1
  63. package/types/array/group-by.d.ts +1 -1
  64. package/types/array/index-of.d.ts +1 -1
  65. package/types/array/index.d.ts +1 -1
  66. package/types/array/insert.d.ts +1 -1
  67. package/types/array/models.d.ts +1 -1
  68. package/types/array/sort.d.ts +2 -2
  69. package/types/array/to-map.d.ts +1 -1
  70. package/types/array/to-record.d.ts +1 -1
  71. package/types/array/unique.d.ts +1 -1
  72. package/types/colour/base.d.ts +1 -1
  73. package/types/colour/functions.d.ts +3 -3
  74. package/types/colour/hex.d.ts +2 -2
  75. package/types/colour/hsl.d.ts +3 -3
  76. package/types/colour/index.d.ts +1 -1
  77. package/types/colour/is.d.ts +3 -3
  78. package/types/colour/rgb.d.ts +3 -3
  79. package/types/function.d.ts +1 -1
  80. package/types/index.d.cts +8 -2
  81. package/types/index.d.ts +16 -16
  82. package/types/internal/array/callbacks.d.ts +1 -1
  83. package/types/internal/array/find.d.ts +1 -1
  84. package/types/internal/value/handle.d.ts +1 -1
  85. package/types/is.d.ts +1 -1
  86. package/types/models.d.cts +8 -2
  87. package/types/query.d.ts +1 -1
  88. package/types/string/template.d.ts +1 -1
  89. package/types/value/get.d.cts +8 -2
  90. package/types/value/get.d.ts +1 -1
  91. package/types/value/index.d.cts +8 -2
  92. package/types/value/index.d.ts +1 -1
  93. package/types/value/merge.d.ts +1 -1
  94. package/types/value/set.d.ts +1 -1
  95. package/types/value/smush.d.cts +8 -2
  96. package/types/value/smush.d.ts +1 -1
  97. 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(
@@ -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(
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -9,11 +9,11 @@
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.9",
13
13
  "@vitest/coverage-istanbul": "^2.1",
14
14
  "dts-bundle-generator": "^9.5",
15
15
  "glob": "^11",
16
- "happy-dom": "^15.7",
16
+ "happy-dom": "^15.11",
17
17
  "typescript": "^5.6",
18
18
  "vite": "^5.4",
19
19
  "vitest": "^2.1"
@@ -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.79.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
package/src/array/sort.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type {SortKey, SortKeyWithCallback} from '~/array/models';
2
- import {isKey} from '~/is';
3
- import type {Key, PlainObject} from '~/models';
4
- import {compare} from '~/value/compare';
1
+ import {isKey} from '../is';
2
+ import type {Key, PlainObject} from '../models';
3
+ import {compare} from '../value/compare';
4
+ import type {SortKey, SortKeyWithCallback} from './models';
5
5
 
6
6
  /**
7
7
  * Sort an array of items _(defaults to ascending)_
@@ -57,13 +57,7 @@ export function sort(
57
57
  return array;
58
58
  }
59
59
 
60
- if (first == null || typeof first === 'boolean') {
61
- return first === true
62
- ? (array as never[]).sort((first, second) => second - first)
63
- : array.sort();
64
- }
65
-
66
- const direction = second === true ? 'desc' : 'asc';
60
+ const direction = first === true || second === true ? 'desc' : 'asc';
67
61
 
68
62
  const keys = (Array.isArray(first) ? first : [first])
69
63
  .map(key => {
@@ -92,9 +86,11 @@ export function sort(
92
86
  const {length} = keys;
93
87
 
94
88
  if (length === 0) {
95
- return direction === 'asc'
96
- ? array.sort()
97
- : (array as never[]).sort((first, second) => second - first);
89
+ return array.sort(
90
+ (first, second) =>
91
+ compare(first as never, second as never) *
92
+ (direction === 'asc' ? 1 : -1),
93
+ );
98
94
  }
99
95
 
100
96
  if (length === 1) {
@@ -1,4 +1,4 @@
1
- import {insertValues} from '~/array/insert';
1
+ import {insertValues} from './insert';
2
2
 
3
3
  /**
4
4
  * Removes and returns all items from an array starting from a specific index
@@ -1,5 +1,5 @@
1
- import {getCallbacks} from '~/internal/array/callbacks';
2
- import type {Key, PlainObject} from '~/models';
1
+ import {getCallbacks} from '../internal/array/callbacks';
2
+ import type {Key, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Create a map from an array of items _(using their indices as keys)_
@@ -1,6 +1,6 @@
1
1
  import type {Simplify} from 'type-fest';
2
- import {groupValues} from '~/array/group-by';
3
- import type {Key, KeyedValue, PlainObject} from '~/models';
2
+ import {groupValues} from '../array/group-by';
3
+ import type {Key, KeyedValue, PlainObject} from '../models';
4
4
 
5
5
  /**
6
6
  * Create a record from an array of items _(using their indices as keys)_
@@ -11,18 +11,18 @@ export function toRecord<Item>(array: Item[]): Record<number, Item>;
11
11
  * Create a record from an array of items using a specific key
12
12
  */
13
13
  export function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(
14
- array: Item[],
15
- key: ItemKey,
16
- ): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
14
+ array: Item[],
15
+ key: ItemKey,
16
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
17
17
 
18
18
  /**
19
19
  * Create a record from an array of items using a specific key, and grouping them into arrays
20
20
  */
21
21
  export function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(
22
- array: Item[],
23
- key: ItemKey,
24
- arrays: true,
25
- ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
22
+ array: Item[],
23
+ key: ItemKey,
24
+ arrays: true,
25
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
26
26
 
27
27
  /**
28
28
  * Create a record from an array of items using a specific key
@@ -48,82 +48,82 @@ export function toRecord<
48
48
  * Create a record from an array of items using a specific key and value
49
49
  */
50
50
  export function toRecord<
51
- Item extends PlainObject,
52
- ItemKey extends keyof Item,
53
- ItemValue extends keyof Item,
54
- >(
55
- array: Item[],
56
- key: ItemKey,
57
- value: ItemValue,
58
- ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
51
+ Item extends PlainObject,
52
+ ItemKey extends keyof Item,
53
+ ItemValue extends keyof Item,
54
+ >(
55
+ array: Item[],
56
+ key: ItemKey,
57
+ value: ItemValue,
58
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
59
59
 
60
60
  /**
61
61
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
62
62
  */
63
63
  export function toRecord<
64
- Item extends PlainObject,
65
- ItemKey extends keyof Item,
66
- ItemValue extends keyof Item,
67
- >(
68
- array: Item[],
69
- key: ItemKey,
70
- value: ItemValue,
71
- arrays: true,
72
- ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<Item[ItemValue]>>>;
64
+ Item extends PlainObject,
65
+ ItemKey extends keyof Item,
66
+ ItemValue extends keyof Item,
67
+ >(
68
+ array: Item[],
69
+ key: ItemKey,
70
+ value: ItemValue,
71
+ arrays: true,
72
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<Item[ItemValue]>>>;
73
73
 
74
74
  /**
75
75
  * Create a record from an array of items using a specific key and value
76
76
  */
77
77
  export function toRecord<
78
- Item extends PlainObject,
79
- ItemKey extends keyof Item,
80
- ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
81
- >(
82
- array: Item[],
83
- key: ItemKey,
84
- value: ItemValue,
85
- ): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>>;
78
+ Item extends PlainObject,
79
+ ItemKey extends keyof Item,
80
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
81
+ >(
82
+ array: Item[],
83
+ key: ItemKey,
84
+ value: ItemValue,
85
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>>;
86
86
 
87
87
  /**
88
88
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
89
89
  */
90
90
  export function toRecord<
91
- Item extends PlainObject,
92
- ItemKey extends keyof Item,
93
- ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
94
- >(
95
- array: Item[],
96
- key: ItemKey,
97
- value: ItemValue,
98
- arrays: true,
99
- ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>>;
91
+ Item extends PlainObject,
92
+ ItemKey extends keyof Item,
93
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
94
+ >(
95
+ array: Item[],
96
+ key: ItemKey,
97
+ value: ItemValue,
98
+ arrays: true,
99
+ ): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>>;
100
100
 
101
101
  /**
102
102
  * Create a record from an array of items using a specific key and value
103
103
  */
104
104
  export function toRecord<
105
- Item extends PlainObject,
106
- ItemKey extends (item: Item, index: number, array: Item[]) => Key,
107
- ItemValue extends keyof Item,
108
- >(
109
- array: Item[],
110
- key: ItemKey,
111
- value: ItemValue,
112
- ): Record<ReturnType<ItemKey>, Item[ItemValue]>;
105
+ Item extends PlainObject,
106
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
107
+ ItemValue extends keyof Item,
108
+ >(
109
+ array: Item[],
110
+ key: ItemKey,
111
+ value: ItemValue,
112
+ ): Record<ReturnType<ItemKey>, Item[ItemValue]>;
113
113
 
114
114
  /**
115
115
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
116
116
  */
117
117
  export function toRecord<
118
- Item extends PlainObject,
119
- ItemKey extends (item: Item, index: number, array: Item[]) => Key,
120
- ItemValue extends keyof Item,
121
- >(
122
- array: Item[],
123
- key: ItemKey,
124
- value: ItemValue,
125
- arrays: true,
126
- ): Record<ReturnType<ItemKey>, Array<Item[ItemValue]>>;
118
+ Item extends PlainObject,
119
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
120
+ ItemValue extends keyof Item,
121
+ >(
122
+ array: Item[],
123
+ key: ItemKey,
124
+ value: ItemValue,
125
+ arrays: true,
126
+ ): Record<ReturnType<ItemKey>, Array<Item[ItemValue]>>;
127
127
 
128
128
  /**
129
129
  * Create a record from an array of items using a specific key and value
@@ -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 an array of unique items
@@ -20,9 +20,9 @@ export function unique<Item extends PlainObject, ItemKey extends keyof Item>(
20
20
  * - Use `key` to find a comparison value for an item
21
21
  */
22
22
  export function unique<
23
- Item,
24
- ItemKey extends (item: Item, index: number, array: Item[]) => Key,
25
- >(array: Item[], key: ItemKey): Item[];
23
+ Item,
24
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
25
+ >(array: Item[], key: ItemKey): Item[];
26
26
 
27
27
  export function unique(array: unknown[], key?: unknown): unknown[] {
28
28
  return findValues('unique', array, [key, undefined]);
@@ -1,5 +1,5 @@
1
- import type {HexColour} from '~/colour/hex';
2
- import {isColourValue} from '~/colour/is';
1
+ import type {HexColour} from './hex';
2
+ import {isColourValue} from './is';
3
3
 
4
4
  export abstract class Colour<Model> {
5
5
  private declare readonly $colour: string;
@@ -1,7 +1,7 @@
1
- import {HexColour} from '~/colour/hex';
2
- import {HSLColour, type HSLColourValue} from '~/colour/hsl';
3
- import {RGBColour, type RGBColourValue} from '~/colour/rgb';
4
- import {clamp} from '~/number';
1
+ import {clamp} from '../number';
2
+ import {HexColour} from './hex';
3
+ import {HSLColour, type HSLColourValue} from './hsl';
4
+ import {RGBColour, type RGBColourValue} from './rgb';
5
5
 
6
6
  export const anyPattern = /^#*([a-f0-9]{3}){1,2}$/i;
7
7
  const groupedPattern = /^#*([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
package/src/colour/hex.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {anyPattern, getNormalisedHex, hexToRgb} from '~/colour/functions';
2
- import type {HSLColour} from '~/colour/hsl';
3
- import type {RGBColour} from '~/colour/rgb';
1
+ import {anyPattern, getNormalisedHex, hexToRgb} from './functions';
2
+ import type {HSLColour} from './hsl';
3
+ import type {RGBColour} from './rgb';
4
4
 
5
5
  type State = {
6
6
  value: string;
package/src/colour/hsl.ts CHANGED
@@ -1,8 +1,8 @@
1
- import {Colour} from '~/colour/base';
2
- import {hslToRgb} from '~/colour/functions';
3
- import type {HexColour} from '~/colour/hex';
4
- import type {RGBColour} from '~/colour/rgb';
5
- import {clamp} from '~/number';
1
+ import {clamp} from '../number';
2
+ import {Colour} from './base';
3
+ import {hslToRgb} from './functions';
4
+ import type {HexColour} from './hex';
5
+ import type {RGBColour} from './rgb';
6
6
 
7
7
  export type HSLColourValue = {
8
8
  hue: number;
@@ -1,4 +1,4 @@
1
- import type {RGBColourValue} from '~/colour/rgb';
1
+ import type {RGBColourValue} from './rgb';
2
2
 
3
3
  /**
4
4
  * Get a foreground colour _(usually text)_ based on a background colour's luminance
package/src/colour/is.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type {HexColour} from '~/colour/hex';
2
- import type {HSLColour} from '~/colour/hsl';
3
- import type {RGBColour} from '~/colour/rgb';
1
+ import type {HexColour} from './hex';
2
+ import type {HSLColour} from './hsl';
3
+ import type {RGBColour} from './rgb';
4
4
 
5
5
  /**
6
6
  * Is the value a colour?
package/src/colour/rgb.ts CHANGED
@@ -1,8 +1,8 @@
1
- import {Colour} from '~/colour/base';
2
- import {rgbToHex, rgbToHsl} from '~/colour/functions';
3
- import type {HexColour} from '~/colour/hex';
4
- import type {HSLColour} from '~/colour/hsl';
5
- import {clamp} from '~/number';
1
+ import {clamp} from '../number';
2
+ import {Colour} from './base';
3
+ import {rgbToHex, rgbToHsl} from './functions';
4
+ import type {HexColour} from './hex';
5
+ import type {HSLColour} from './hsl';
6
6
 
7
7
  export type RGBColourValue = {
8
8
  blue: number;
package/src/emitter.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {noop} from '~/function';
1
+ import {noop} from './function';
2
2
 
3
3
  class Emitter<Value> {
4
4
  private declare readonly state: EmitterState<Value>;
package/src/function.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type {GenericCallback} from '~/models';
2
- import {clamp} from '~/number';
1
+ import type {GenericCallback} from './models';
2
+ import {clamp} from './number';
3
3
 
4
4
  type Debounced<Callback extends GenericCallback> = Callback & {
5
5
  /**