@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.
- package/dist/array/sort.cjs +4 -5
- package/dist/array/sort.js +4 -5
- package/dist/colour/functions.cjs +1 -1
- package/dist/colour/functions.js +1 -1
- package/dist/colour/hsl.cjs +1 -1
- package/dist/colour/hsl.js +1 -1
- package/dist/colour/rgb.cjs +1 -1
- package/dist/colour/rgb.js +1 -1
- package/dist/value/equal.cjs +4 -1
- package/dist/value/equal.js +4 -1
- package/package.json +12 -5
- package/src/array/chunk.ts +1 -1
- package/src/array/count.ts +2 -2
- package/src/array/exists.ts +2 -2
- package/src/array/filter.ts +2 -2
- package/src/array/find.ts +2 -2
- package/src/array/group-by.ts +2 -2
- package/src/array/index-of.ts +2 -2
- package/src/array/index.ts +3 -2
- package/src/array/insert.ts +2 -2
- package/src/array/models.ts +1 -1
- package/src/array/shuffle.ts +1 -1
- package/src/array/sort.ts +10 -14
- package/src/array/splice.ts +1 -1
- package/src/array/to-map.ts +2 -2
- package/src/array/to-record.ts +60 -60
- package/src/array/unique.ts +5 -5
- package/src/colour/base.ts +2 -2
- package/src/colour/functions.ts +4 -4
- package/src/colour/hex.ts +3 -3
- package/src/colour/hsl.ts +5 -5
- package/src/colour/index.ts +1 -1
- package/src/colour/is.ts +3 -3
- package/src/colour/rgb.ts +5 -5
- package/src/emitter.ts +1 -1
- package/src/function.ts +2 -2
- package/src/index.ts +16 -16
- package/src/internal/array/callbacks.ts +2 -2
- package/src/internal/array/find.ts +2 -2
- package/src/internal/value/handle.ts +1 -1
- package/src/is.ts +2 -2
- package/src/logger.ts +1 -1
- package/src/query.ts +4 -4
- package/src/random.ts +1 -1
- package/src/sized.ts +1 -1
- package/src/string/case.ts +1 -1
- package/src/string/index.ts +2 -1
- package/src/string/template.ts +3 -3
- package/src/value/clone.ts +3 -3
- package/src/value/compare.ts +3 -3
- package/src/value/diff.ts +4 -4
- package/src/value/equal.ts +6 -3
- package/src/value/get.ts +2 -2
- package/src/value/index.ts +2 -1
- package/src/value/merge.ts +2 -2
- package/src/value/set.ts +2 -2
- package/src/value/smush.ts +3 -3
- package/src/value/unsmush.ts +3 -3
- package/types/array/count.d.ts +1 -1
- package/types/array/exists.d.ts +1 -1
- package/types/array/filter.d.ts +1 -1
- package/types/array/find.d.ts +1 -1
- package/types/array/group-by.d.ts +1 -1
- package/types/array/index-of.d.ts +1 -1
- package/types/array/index.d.ts +1 -1
- package/types/array/insert.d.ts +1 -1
- package/types/array/models.d.ts +1 -1
- package/types/array/sort.d.ts +2 -2
- package/types/array/to-map.d.ts +1 -1
- package/types/array/to-record.d.ts +1 -1
- package/types/array/unique.d.ts +1 -1
- package/types/colour/base.d.ts +1 -1
- package/types/colour/functions.d.ts +3 -3
- package/types/colour/hex.d.ts +2 -2
- package/types/colour/hsl.d.ts +3 -3
- package/types/colour/index.d.ts +1 -1
- package/types/colour/is.d.ts +3 -3
- package/types/colour/rgb.d.ts +3 -3
- package/types/function.d.ts +1 -1
- package/types/index.d.cts +8 -2
- package/types/index.d.ts +16 -16
- package/types/internal/array/callbacks.d.ts +1 -1
- package/types/internal/array/find.d.ts +1 -1
- package/types/internal/value/handle.d.ts +1 -1
- package/types/is.d.ts +1 -1
- package/types/models.d.cts +8 -2
- package/types/query.d.ts +1 -1
- package/types/string/template.d.ts +1 -1
- package/types/value/get.d.cts +8 -2
- package/types/value/get.d.ts +1 -1
- package/types/value/index.d.cts +8 -2
- package/types/value/index.d.ts +1 -1
- package/types/value/merge.d.ts +1 -1
- package/types/value/set.d.ts +1 -1
- package/types/value/smush.d.cts +8 -2
- package/types/value/smush.d.ts +1 -1
- package/types/value/unsmush.d.ts +1 -1
package/dist/array/sort.cjs
CHANGED
|
@@ -6,10 +6,7 @@ function sort(array, first, second) {
|
|
|
6
6
|
if (array.length < 2) {
|
|
7
7
|
return array;
|
|
8
8
|
}
|
|
9
|
-
|
|
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
|
|
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(
|
package/dist/array/sort.js
CHANGED
|
@@ -4,10 +4,7 @@ function sort(array, first, second) {
|
|
|
4
4
|
if (array.length < 2) {
|
|
5
5
|
return array;
|
|
6
6
|
}
|
|
7
|
-
|
|
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
|
|
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) {
|
package/dist/colour/functions.js
CHANGED
|
@@ -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) {
|
package/dist/colour/hsl.cjs
CHANGED
|
@@ -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
|
package/dist/colour/hsl.js
CHANGED
package/dist/colour/rgb.cjs
CHANGED
|
@@ -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
|
package/dist/colour/rgb.js
CHANGED
package/dist/value/equal.cjs
CHANGED
|
@@ -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(
|
|
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:
|
package/dist/value/equal.js
CHANGED
|
@@ -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(
|
|
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.
|
|
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.
|
|
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": [
|
|
183
|
-
|
|
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.
|
|
208
|
+
"version": "0.79.0"
|
|
202
209
|
}
|
package/src/array/chunk.ts
CHANGED
package/src/array/count.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {findValues} from '
|
|
2
|
-
import type {Key, PlainObject} from '
|
|
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
|
package/src/array/exists.ts
CHANGED
package/src/array/filter.ts
CHANGED
package/src/array/find.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {findValue} from '
|
|
2
|
-
import type {Key, PlainObject} from '
|
|
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)_
|
package/src/array/group-by.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {Simplify} from 'type-fest';
|
|
2
|
-
import {getCallbacks} from '
|
|
3
|
-
import type {Key, KeyedValue, PlainObject} from '
|
|
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
|
package/src/array/index-of.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {findValue} from '
|
|
2
|
-
import type {Key, PlainObject} from '
|
|
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)_
|
package/src/array/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {insertValues} from '
|
|
2
|
-
import type {NestedArrayType} from '
|
|
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
|
+
|
package/src/array/insert.ts
CHANGED
package/src/array/models.ts
CHANGED
package/src/array/shuffle.ts
CHANGED
package/src/array/sort.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
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
|
-
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
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) {
|
package/src/array/splice.ts
CHANGED
package/src/array/to-map.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {getCallbacks} from '
|
|
2
|
-
import type {Key, PlainObject} from '
|
|
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)_
|
package/src/array/to-record.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {Simplify} from 'type-fest';
|
|
2
|
-
import {groupValues} from '
|
|
3
|
-
import type {Key, KeyedValue, PlainObject} from '
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
package/src/array/unique.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {findValues} from '
|
|
2
|
-
import type {Key, PlainObject} from '
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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]);
|
package/src/colour/base.ts
CHANGED
package/src/colour/functions.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 '
|
|
2
|
-
import type {HSLColour} from '
|
|
3
|
-
import type {RGBColour} from '
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
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;
|
package/src/colour/index.ts
CHANGED
package/src/colour/is.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {HexColour} from '
|
|
2
|
-
import type {HSLColour} from '
|
|
3
|
-
import type {RGBColour} from '
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
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
package/src/function.ts
CHANGED