@oscarpalmer/atoms 0.111.1 → 0.113.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/get.js +9 -11
- package/dist/array/sort.js +17 -3
- package/dist/atoms.full.js +897 -503
- package/dist/color/constants.js +35 -9
- package/dist/color/index.js +7 -66
- package/dist/color/instance.js +58 -0
- package/dist/color/misc/alpha.js +27 -0
- package/dist/color/misc/foreground.js +15 -0
- package/dist/color/misc/is.js +56 -0
- package/dist/color/misc/state.js +81 -0
- package/dist/color/space/hex.js +51 -0
- package/dist/color/space/hsl.js +49 -0
- package/dist/color/space/rgb.js +84 -0
- package/dist/function.js +2 -1
- package/dist/index.js +7 -3
- package/dist/internal/array/callbacks.js +1 -0
- package/dist/internal/array/chunk.js +2 -1
- package/dist/internal/array/find.js +11 -6
- package/dist/internal/array/insert.js +9 -5
- package/dist/internal/function.js +4 -4
- package/dist/internal/is.js +2 -2
- package/dist/internal/math/aggregate.js +7 -7
- package/dist/internal/number.js +23 -14
- package/dist/internal/string.js +4 -4
- package/dist/internal/value/equal.js +12 -10
- package/dist/internal/value/misc.js +5 -5
- package/dist/internal/value/set.js +2 -2
- package/dist/is.js +4 -4
- package/dist/query.js +14 -13
- package/dist/random.js +11 -7
- package/dist/sized.js +20 -9
- package/dist/string/case.js +5 -4
- package/dist/string/misc.js +4 -5
- package/dist/string/template.js +4 -3
- package/dist/value/clone.js +9 -8
- package/dist/value/diff.js +43 -27
- package/dist/value/merge.js +20 -12
- package/dist/value/smush.js +2 -1
- package/dist/value/unsmush.js +3 -1
- package/package.json +7 -6
- package/src/array/exists.ts +14 -14
- package/src/array/filter.ts +12 -12
- package/src/array/find.ts +6 -6
- package/src/array/get.ts +18 -18
- package/src/array/group-by.ts +53 -36
- package/src/array/index-of.ts +10 -10
- package/src/array/insert.ts +9 -9
- package/src/array/push.ts +4 -4
- package/src/array/sort.ts +46 -24
- package/src/array/splice.ts +14 -14
- package/src/array/to-map.ts +48 -36
- package/src/array/to-record.ts +46 -34
- package/src/array/to-set.ts +5 -5
- package/src/array/unique.ts +5 -5
- package/src/color/constants.ts +61 -9
- package/src/color/index.ts +29 -131
- package/src/color/instance.ts +123 -0
- package/src/color/misc/alpha.ts +62 -0
- package/src/color/misc/foreground.ts +48 -0
- package/src/color/misc/is.ts +156 -0
- package/src/color/misc/state.ts +146 -0
- package/src/color/models.ts +15 -0
- package/src/color/space/hex.ts +110 -0
- package/src/color/space/hsl.ts +114 -0
- package/src/color/space/rgb.ts +157 -0
- package/src/emitter.ts +6 -6
- package/src/function.ts +17 -10
- package/src/internal/array/callbacks.ts +3 -0
- package/src/internal/array/chunk.ts +7 -1
- package/src/internal/array/compact.ts +1 -0
- package/src/internal/array/find.ts +28 -7
- package/src/internal/array/insert.ts +42 -20
- package/src/internal/array/shuffle.ts +2 -2
- package/src/internal/function.ts +11 -3
- package/src/internal/is.ts +7 -7
- package/src/internal/math/aggregate.ts +20 -20
- package/src/internal/number.ts +30 -24
- package/src/internal/random.ts +2 -2
- package/src/internal/string.ts +7 -7
- package/src/internal/value/compare.ts +6 -3
- package/src/internal/value/equal.ts +47 -24
- package/src/internal/value/get.ts +6 -6
- package/src/internal/value/misc.ts +11 -7
- package/src/internal/value/set.ts +10 -10
- package/src/is.ts +11 -11
- package/src/logger.ts +14 -13
- package/src/math.ts +33 -33
- package/src/models.ts +2 -0
- package/src/query.ts +28 -23
- package/src/random.ts +30 -17
- package/src/sized.ts +48 -32
- package/src/string/case.ts +16 -14
- package/src/string/misc.ts +5 -5
- package/src/string/template.ts +9 -6
- package/src/value/clone.ts +14 -10
- package/src/value/diff.ts +77 -43
- package/src/value/merge.ts +39 -24
- package/src/value/partial.ts +2 -2
- package/src/value/smush.ts +5 -1
- package/src/value/unsmush.ts +7 -9
- package/types/array/exists.d.ts +14 -14
- package/types/array/filter.d.ts +12 -12
- package/types/array/find.d.ts +6 -6
- package/types/array/get.d.ts +3 -3
- package/types/array/group-by.d.ts +52 -34
- package/types/array/index-of.d.ts +10 -10
- package/types/array/insert.d.ts +9 -9
- package/types/array/push.d.ts +4 -4
- package/types/array/splice.d.ts +14 -14
- package/types/array/to-map.d.ts +48 -36
- package/types/array/to-record.d.ts +46 -34
- package/types/array/to-set.d.ts +5 -5
- package/types/array/unique.d.ts +5 -5
- package/types/color/constants.d.ts +32 -9
- package/types/color/index.d.ts +9 -51
- package/types/color/instance.d.ts +56 -0
- package/types/color/misc/alpha.d.ts +3 -0
- package/types/color/misc/foreground.d.ts +7 -0
- package/types/color/misc/is.d.ts +39 -0
- package/types/color/misc/state.d.ts +5 -0
- package/types/color/models.d.ts +12 -1
- package/types/color/space/hex.d.ts +28 -0
- package/types/color/space/hsl.d.ts +30 -0
- package/types/color/space/rgb.d.ts +38 -0
- package/types/function.d.ts +5 -4
- package/types/internal/array/compact.d.ts +1 -0
- package/types/internal/array/insert.d.ts +3 -1
- package/types/internal/array/shuffle.d.ts +2 -2
- package/types/internal/is.d.ts +5 -5
- package/types/internal/math/aggregate.d.ts +9 -9
- package/types/internal/number.d.ts +7 -7
- package/types/internal/random.d.ts +2 -2
- package/types/internal/string.d.ts +3 -3
- package/types/internal/value/compare.d.ts +2 -2
- package/types/internal/value/equal.d.ts +10 -6
- package/types/internal/value/get.d.ts +6 -6
- package/types/internal/value/set.d.ts +8 -8
- package/types/is.d.ts +7 -7
- package/types/logger.d.ts +11 -34
- package/types/math.d.ts +32 -32
- package/types/models.d.ts +2 -0
- package/types/random.d.ts +7 -6
- package/types/sized.d.ts +18 -21
- package/types/string/case.d.ts +5 -5
- package/types/string/misc.d.ts +2 -2
- package/types/string/template.d.ts +3 -3
- package/types/value/diff.d.ts +3 -3
- package/types/value/merge.d.ts +2 -2
- package/types/value/partial.d.ts +2 -2
- package/dist/color/is.js +0 -43
- package/dist/color/misc.js +0 -9
- package/dist/color/state.js +0 -44
- package/dist/color/value.js +0 -72
- package/src/color/is.ts +0 -98
- package/src/color/misc.ts +0 -20
- package/src/color/state.ts +0 -55
- package/src/color/value.ts +0 -145
- package/types/color/is.d.ts +0 -26
- package/types/color/misc.d.ts +0 -6
- package/types/color/state.d.ts +0 -2
- package/types/color/value.d.ts +0 -27
package/dist/array/get.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.js";
|
|
2
2
|
function getArray(value, indiced) {
|
|
3
3
|
if (Array.isArray(value)) return value;
|
|
4
|
-
if (isPlainObject(value))
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return array;
|
|
4
|
+
if (!isPlainObject(value)) return [value];
|
|
5
|
+
if (indiced !== true) return Object.values(value);
|
|
6
|
+
const keys = Object.keys(value);
|
|
7
|
+
const { length } = keys;
|
|
8
|
+
const array = [];
|
|
9
|
+
for (let index = 0; index < length; index += 1) {
|
|
10
|
+
const key = keys[index];
|
|
11
|
+
if (!Number.isNaN(Number(key))) array.push(value[key]);
|
|
14
12
|
}
|
|
15
|
-
return
|
|
13
|
+
return array;
|
|
16
14
|
}
|
|
17
15
|
export { getArray };
|
package/dist/array/sort.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.js";
|
|
2
2
|
import "../is.js";
|
|
3
3
|
import { compare } from "../internal/value/compare.js";
|
|
4
|
+
function getCallback(value, key, isObject) {
|
|
5
|
+
if (key != null) return;
|
|
6
|
+
if (isObject && typeof value.value === "function") return value.value;
|
|
7
|
+
return typeof value === "function" ? value : void 0;
|
|
8
|
+
}
|
|
9
|
+
function getKey(value, isObject) {
|
|
10
|
+
if (isObject && typeof value.key === "string") return value.key;
|
|
11
|
+
return typeof value === "string" ? value : void 0;
|
|
12
|
+
}
|
|
13
|
+
function getModifier(value, modifier, isObject) {
|
|
14
|
+
if (!isObject || typeof value.direction !== "string") return modifier;
|
|
15
|
+
if (value.direction === "ascending") return 1;
|
|
16
|
+
return value.direction === "descending" ? -1 : modifier;
|
|
17
|
+
}
|
|
4
18
|
function getSorter(value, modifier) {
|
|
5
19
|
const isObject = isPlainObject(value);
|
|
6
20
|
const sorter = {
|
|
@@ -8,9 +22,9 @@ function getSorter(value, modifier) {
|
|
|
8
22
|
modifier
|
|
9
23
|
};
|
|
10
24
|
sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
|
|
11
|
-
sorter.key =
|
|
12
|
-
sorter.
|
|
13
|
-
|
|
25
|
+
sorter.key = getKey(value, isObject);
|
|
26
|
+
sorter.modifier = getModifier(value, modifier, isObject);
|
|
27
|
+
sorter.callback = getCallback(value, sorter.key, isObject);
|
|
14
28
|
if (sorter.key != null || sorter.callback != null) {
|
|
15
29
|
sorter.identifier = `${sorter.key ?? sorter.callback}`;
|
|
16
30
|
return sorter;
|