@oscarpalmer/atoms 0.221.0 → 0.223.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/difference.d.mts +1 -3
- package/dist/array/difference.mjs +2 -3
- package/dist/array/exists.d.mts +1 -3
- package/dist/array/exists.mjs +11 -6
- package/dist/array/filter.d.mts +1 -3
- package/dist/array/filter.mjs +15 -6
- package/dist/array/find.d.mts +1 -3
- package/dist/array/find.mjs +9 -5
- package/dist/array/first.d.mts +1 -3
- package/dist/array/first.mjs +10 -5
- package/dist/array/flatten.d.mts +1 -3
- package/dist/array/flatten.mjs +1 -2
- package/dist/array/from.d.mts +1 -3
- package/dist/array/from.mjs +1 -2
- package/dist/array/group-by.d.mts +1 -3
- package/dist/array/group-by.mjs +1 -2
- package/dist/array/index.d.mts +4 -4
- package/dist/array/insert.d.mts +1 -3
- package/dist/array/insert.mjs +2 -3
- package/dist/array/intersection.d.mts +1 -3
- package/dist/array/intersection.mjs +2 -3
- package/dist/array/last.d.mts +1 -3
- package/dist/array/last.mjs +12 -5
- package/dist/array/move.d.mts +1 -3
- package/dist/array/move.mjs +1 -2
- package/dist/array/partition.d.mts +1 -3
- package/dist/array/partition.mjs +24 -5
- package/dist/array/push.d.mts +0 -2
- package/dist/array/push.mjs +2 -3
- package/dist/array/reverse.d.mts +1 -3
- package/dist/array/reverse.mjs +1 -2
- package/dist/array/select.d.mts +0 -2
- package/dist/array/select.mjs +40 -9
- package/dist/array/single.d.mts +1 -3
- package/dist/array/single.mjs +9 -7
- package/dist/array/slice.d.mts +1 -3
- package/dist/array/slice.mjs +1 -2
- package/dist/array/sort.d.mts +0 -2
- package/dist/array/sort.mjs +2 -3
- package/dist/array/splice.d.mts +1 -3
- package/dist/array/splice.mjs +2 -3
- package/dist/array/swap.d.mts +0 -2
- package/dist/array/swap.mjs +2 -3
- package/dist/array/to-map.d.mts +1 -3
- package/dist/array/to-map.mjs +1 -2
- package/dist/array/to-record.d.mts +1 -3
- package/dist/array/to-record.mjs +1 -2
- package/dist/array/to-set.d.mts +1 -3
- package/dist/array/to-set.mjs +1 -2
- package/dist/array/toggle.d.mts +1 -3
- package/dist/array/toggle.mjs +1 -2
- package/dist/array/union.d.mts +1 -3
- package/dist/array/union.mjs +2 -3
- package/dist/array/unique.d.mts +1 -3
- package/dist/array/unique.mjs +18 -5
- package/dist/array/update.d.mts +1 -3
- package/dist/array/update.mjs +1 -2
- package/dist/beacon.d.mts +3 -13
- package/dist/beacon.mjs +10 -21
- package/dist/color/constants.d.mts +1 -7
- package/dist/color/constants.mjs +3 -11
- package/dist/color/index.d.mts +0 -2
- package/dist/color/index.mjs +4 -5
- package/dist/color/instance.d.mts +1 -3
- package/dist/color/instance.mjs +5 -8
- package/dist/color/misc/alpha.d.mts +1 -3
- package/dist/color/misc/alpha.mjs +1 -2
- package/dist/color/misc/format.d.mts +1 -3
- package/dist/color/misc/format.mjs +1 -2
- package/dist/color/misc/get.d.mts +1 -3
- package/dist/color/misc/get.mjs +2 -3
- package/dist/color/misc/is.d.mts +1 -11
- package/dist/color/misc/is.mjs +4 -16
- package/dist/color/misc/state.d.mts +1 -3
- package/dist/color/misc/state.mjs +4 -5
- package/dist/color/space/hex.d.mts +1 -3
- package/dist/color/space/hex.mjs +2 -3
- package/dist/color/space/hsl.d.mts +1 -3
- package/dist/color/space/hsl.mjs +2 -3
- package/dist/color/space/hwb.d.mts +1 -3
- package/dist/color/space/hwb.mjs +3 -4
- package/dist/color/space/rgb.d.mts +1 -3
- package/dist/color/space/rgb.mjs +1 -2
- package/dist/function/limit.d.mts +1 -3
- package/dist/function/limit.mjs +2 -3
- package/dist/function/once.d.mts +1 -3
- package/dist/function/once.mjs +8 -9
- package/dist/function/retry.d.mts +1 -3
- package/dist/function/retry.mjs +11 -12
- package/dist/herald.d.mts +2 -2
- package/dist/herald.mjs +1 -1
- package/dist/index.d.mts +81 -359
- package/dist/index.mjs +514 -661
- package/dist/internal/aborter.d.mts +1 -3
- package/dist/internal/aborter.mjs +1 -2
- package/dist/internal/array/callbacks.d.mts +2 -4
- package/dist/internal/array/callbacks.mjs +1 -2
- package/dist/internal/array/chunk.d.mts +1 -3
- package/dist/internal/array/chunk.mjs +1 -2
- package/dist/internal/array/compact.d.mts +1 -3
- package/dist/internal/array/compact.mjs +1 -2
- package/dist/internal/array/find.d.mts +2 -8
- package/dist/internal/array/find.mjs +31 -124
- package/dist/internal/array/get.d.mts +1 -3
- package/dist/internal/array/get.mjs +1 -2
- package/dist/internal/array/group.d.mts +1 -3
- package/dist/internal/array/group.mjs +1 -2
- package/dist/internal/array/index-of.d.mts +1 -3
- package/dist/internal/array/index-of.mjs +10 -5
- package/dist/internal/array/insert.d.mts +1 -3
- package/dist/internal/array/insert.mjs +2 -3
- package/dist/internal/array/match.d.mts +2 -4
- package/dist/internal/array/match.mjs +2 -3
- package/dist/internal/array/overlap.d.mts +1 -3
- package/dist/internal/array/overlap.mjs +1 -2
- package/dist/internal/array/sets.d.mts +1 -3
- package/dist/internal/array/sets.mjs +5 -6
- package/dist/internal/array/shuffle.d.mts +1 -3
- package/dist/internal/array/shuffle.mjs +1 -2
- package/dist/internal/array/update.d.mts +1 -3
- package/dist/internal/array/update.mjs +1 -2
- package/dist/internal/defaults.d.mts +1 -3
- package/dist/internal/defaults.mjs +1 -2
- package/dist/internal/function/assert.d.mts +1 -3
- package/dist/internal/function/assert.mjs +1 -2
- package/dist/internal/function/limit.d.mts +2 -4
- package/dist/internal/function/limit.mjs +8 -9
- package/dist/internal/function/memoize.d.mts +1 -3
- package/dist/internal/function/memoize.mjs +4 -5
- package/dist/internal/function/misc.d.mts +1 -2
- package/dist/internal/function/misc.mjs +7 -3
- package/dist/internal/function/work.d.mts +1 -3
- package/dist/internal/function/work.mjs +5 -13
- package/dist/internal/herald.d.mts +2 -12
- package/dist/internal/herald.mjs +9 -33
- package/dist/internal/is.d.mts +1 -3
- package/dist/internal/is.mjs +1 -2
- package/dist/internal/math/aggregate.d.mts +1 -3
- package/dist/internal/math/aggregate.mjs +2 -3
- package/dist/internal/math/misc.d.mts +1 -3
- package/dist/internal/math/misc.mjs +1 -2
- package/dist/internal/number.d.mts +1 -3
- package/dist/internal/number.mjs +2 -3
- package/dist/internal/plan/index.d.mts +1 -3
- package/dist/internal/plan/index.mjs +2 -3
- package/dist/internal/plan/plan.generate.d.mts +1 -3
- package/dist/internal/plan/plan.generate.mjs +67 -22
- package/dist/internal/random.d.mts +1 -3
- package/dist/internal/random.mjs +1 -2
- package/dist/internal/result/attempt.d.mts +1 -3
- package/dist/internal/result/attempt.mjs +1 -2
- package/dist/internal/result/misc.d.mts +1 -3
- package/dist/internal/result/misc.mjs +1 -2
- package/dist/internal/sized/map.d.mts +4 -3
- package/dist/internal/sized/map.mjs +4 -2
- package/dist/internal/sized/misc.d.mts +1 -3
- package/dist/internal/sized/misc.mjs +1 -2
- package/dist/internal/string/case.d.mts +1 -3
- package/dist/internal/string/case.mjs +3 -4
- package/dist/internal/string/misc.d.mts +1 -3
- package/dist/internal/string/misc.mjs +1 -2
- package/dist/internal/subscription.d.mts +1 -3
- package/dist/internal/subscription.mjs +16 -29
- package/dist/internal/value/compare.d.mts +1 -3
- package/dist/internal/value/compare.mjs +2 -3
- package/dist/internal/value/equal.d.mts +1 -3
- package/dist/internal/value/equal.mjs +3 -4
- package/dist/internal/value/get.d.mts +1 -3
- package/dist/internal/value/get.mjs +1 -2
- package/dist/internal/value/handlers.d.mts +1 -3
- package/dist/internal/value/handlers.mjs +1 -2
- package/dist/internal/value/has.d.mts +1 -3
- package/dist/internal/value/has.mjs +1 -2
- package/dist/internal/value/misc.d.mts +1 -3
- package/dist/internal/value/misc.mjs +2 -3
- package/dist/internal/value/partial.d.mts +1 -3
- package/dist/internal/value/partial.mjs +1 -2
- package/dist/internal/value/set.d.mts +1 -3
- package/dist/internal/value/set.mjs +2 -3
- package/dist/is.d.mts +0 -2
- package/dist/is.mjs +2 -3
- package/dist/logger.d.mts +0 -2
- package/dist/logger.mjs +7 -7
- package/dist/math.d.mts +0 -2
- package/dist/math.mjs +2 -3
- package/dist/models/aborter.model.d.mts +1 -3
- package/dist/models/aborter.model.mjs +1 -2
- package/dist/models/array/array.match.model.d.mts +1 -3
- package/dist/models/array/array.match.model.mjs +1 -2
- package/dist/models/array/array.misc.model.d.mts +11 -2
- package/dist/models/array/array.misc.model.mjs +3 -3
- package/dist/models/array/array.sort.model.d.mts +1 -3
- package/dist/models/array/array.sort.model.mjs +1 -2
- package/dist/models/beacon.model.d.mts +4 -6
- package/dist/models/beacon.model.mjs +3 -10
- package/dist/models/color.model.d.mts +2 -4
- package/dist/models/function/assert.model.d.mts +1 -3
- package/dist/models/function/assert.model.mjs +1 -2
- package/dist/models/function/limiter.model.d.mts +2 -4
- package/dist/models/function/limiter.model.mjs +2 -4
- package/dist/models/function/memoize.model.d.mts +2 -4
- package/dist/models/function/memoize.model.mjs +1 -2
- package/dist/models/function/once.model.d.mts +0 -3
- package/dist/models/function/once.model.mjs +3 -5
- package/dist/models/function/retry.model.d.mts +1 -3
- package/dist/models/function/retry.model.mjs +1 -2
- package/dist/models/function/work.model.d.mts +2 -4
- package/dist/models/function/work.model.mjs +1 -2
- package/dist/models/herald.model.d.mts +8 -7
- package/dist/models/herald.model.mjs +3 -10
- package/dist/models/index.d.mts +0 -2
- package/dist/models/logger.model.d.mts +1 -4
- package/dist/models/logger.model.mjs +3 -5
- package/dist/models/math.model.d.mts +1 -3
- package/dist/models/math.model.mjs +1 -2
- package/dist/models/misc.model.d.mts +1 -3
- package/dist/models/misc.model.mjs +1 -2
- package/dist/models/plan.model.d.mts +35 -37
- package/dist/models/plan.model.mjs +1 -2
- package/dist/models/promise.model.d.mts +8 -10
- package/dist/models/promise.model.mjs +4 -5
- package/dist/models/query.model.d.mts +1 -3
- package/dist/models/query.model.mjs +1 -2
- package/dist/models/queue.model.d.mts +0 -3
- package/dist/models/queue.model.mjs +3 -5
- package/dist/models/random.model.d.mts +1 -3
- package/dist/models/random.model.mjs +1 -2
- package/dist/models/result.model.d.mts +0 -2
- package/dist/models/string/string.case.model.d.mts +1 -3
- package/dist/models/string/string.case.model.mjs +1 -2
- package/dist/models/string/string.fuzzy.model.d.mts +0 -3
- package/dist/models/string/string.fuzzy.model.mjs +3 -5
- package/dist/models/string/string.misc.model.d.mts +1 -3
- package/dist/models/string/string.misc.model.mjs +1 -2
- package/dist/models/string/string.normalize.model.d.mts +1 -3
- package/dist/models/string/string.normalize.model.mjs +1 -2
- package/dist/models/string/string.template.model.d.mts +1 -3
- package/dist/models/string/string.template.model.mjs +1 -2
- package/dist/models/subscription.model.d.mts +4 -23
- package/dist/models/subscription.model.mjs +3 -5
- package/dist/models/value/value.clone.model.d.mts +1 -3
- package/dist/models/value/value.clone.model.mjs +1 -2
- package/dist/models/value/value.diff.model.d.mts +1 -3
- package/dist/models/value/value.diff.model.mjs +1 -2
- package/dist/models/value/value.equal.model.d.mts +0 -2
- package/dist/models/value/value.equal.model.mjs +1 -2
- package/dist/models/value/value.handler.model.d.mts +1 -3
- package/dist/models/value/value.merge.model.d.mts +0 -2
- package/dist/models/value/value.merge.model.mjs +1 -2
- package/dist/models/value/value.misc.model.d.mts +0 -2
- package/dist/models/value/value.misc.model.mjs +1 -2
- package/dist/models/value/value.transform.model.d.mts +1 -3
- package/dist/models/value/value.transform.model.mjs +1 -2
- package/dist/plan/index.d.mts +1 -3
- package/dist/plan/index.mjs +2 -3
- package/dist/plan/is.d.mts +1 -3
- package/dist/plan/is.mjs +1 -2
- package/dist/plan/misc.d.mts +1 -3
- package/dist/plan/misc.mjs +2 -3
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +8 -10
- package/dist/plan/result.mjs +2 -3
- package/dist/plan/run.d.mts +8 -10
- package/dist/plan/run.mjs +2 -3
- package/dist/plan/use.d.mts +1 -3
- package/dist/plan/use.mjs +14 -9
- package/dist/promise/delay.d.mts +1 -3
- package/dist/promise/delay.mjs +2 -3
- package/dist/promise/helpers.d.mts +1 -3
- package/dist/promise/helpers.mjs +2 -3
- package/dist/promise/index.d.mts +0 -2
- package/dist/promise/index.mjs +5 -6
- package/dist/promise/misc.d.mts +1 -3
- package/dist/promise/misc.mjs +2 -3
- package/dist/promise/models.d.mts +2 -2
- package/dist/promise/models.mjs +1 -1
- package/dist/promise/timed.d.mts +1 -3
- package/dist/promise/timed.mjs +4 -5
- package/dist/query.d.mts +1 -3
- package/dist/query.mjs +2 -3
- package/dist/queue.d.mts +0 -2
- package/dist/queue.mjs +11 -12
- package/dist/random.d.mts +0 -2
- package/dist/random.mjs +2 -3
- package/dist/result/match.d.mts +1 -3
- package/dist/result/match.mjs +1 -2
- package/dist/result/misc.d.mts +0 -2
- package/dist/result/misc.mjs +1 -2
- package/dist/result/work/flow.d.mts +1 -3
- package/dist/result/work/flow.mjs +5 -12
- package/dist/result/work/pipe.d.mts +0 -2
- package/dist/result/work/pipe.mjs +2 -3
- package/dist/sized/set.d.mts +4 -3
- package/dist/sized/set.mjs +4 -2
- package/dist/string/fuzzy.d.mts +0 -2
- package/dist/string/fuzzy.mjs +5 -7
- package/dist/string/index.d.mts +0 -2
- package/dist/string/index.mjs +2 -3
- package/dist/string/match.d.mts +1 -3
- package/dist/string/match.mjs +2 -3
- package/dist/string/normalize.d.mts +0 -2
- package/dist/string/normalize.mjs +3 -4
- package/dist/string/template.d.mts +0 -2
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -2
- package/dist/value/clone.d.mts +1 -3
- package/dist/value/clone.mjs +2 -3
- package/dist/value/collection.d.mts +1 -3
- package/dist/value/collection.mjs +1 -2
- package/dist/value/diff.d.mts +0 -2
- package/dist/value/diff.mjs +1 -2
- package/dist/value/freeze.d.mts +1 -3
- package/dist/value/freeze.mjs +1 -2
- package/dist/value/handle.mjs +1 -1
- package/dist/value/merge.d.mts +0 -2
- package/dist/value/merge.mjs +1 -2
- package/dist/value/omit.d.mts +1 -3
- package/dist/value/omit.mjs +1 -2
- package/dist/value/pick.d.mts +1 -3
- package/dist/value/pick.mjs +1 -2
- package/dist/value/shake.d.mts +0 -2
- package/dist/value/shake.mjs +1 -2
- package/dist/value/smush.d.mts +0 -2
- package/dist/value/smush.mjs +2 -3
- package/dist/value/transform.d.mts +0 -2
- package/dist/value/transform.mjs +1 -2
- package/dist/value/unsmush.d.mts +0 -2
- package/dist/value/unsmush.mjs +1 -2
- package/package.json +6 -6
- package/dist/models/array/array.find.model.d.mts +0 -48
- package/dist/models/array/array.find.model.mjs +0 -8
package/dist/array/sort.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
|
-
import { floor, round } from "../internal/math/misc.mjs";
|
|
3
2
|
import { min } from "../internal/math/aggregate.mjs";
|
|
3
|
+
import { floor, round } from "../internal/math/misc.mjs";
|
|
4
4
|
import { compare } from "../internal/value/compare.mjs";
|
|
5
5
|
import { SORTER_SYMBOL, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, arrayModifiers } from "../models/array/array.sort.model.mjs";
|
|
6
|
-
|
|
6
|
+
// src/array/sort.ts
|
|
7
7
|
function Sorter(sorters) {
|
|
8
8
|
this[SORTER_SYMBOL] = sorters;
|
|
9
9
|
}
|
|
@@ -135,5 +135,4 @@ function sortArray(array) {
|
|
|
135
135
|
sort.getIndex = getSortedIndex;
|
|
136
136
|
sort.initialize = initializeSorter;
|
|
137
137
|
sort.is = isSorted;
|
|
138
|
-
//#endregion
|
|
139
138
|
export { SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, getSortedIndex, initializeSorter, isSorted, sort };
|
package/dist/array/splice.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/array/splice.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Adds items into an array at a specific index and removes a specific amount of items
|
|
4
3
|
*
|
|
@@ -78,5 +77,4 @@ export declare function splice<Item>(array: Item[], start: number, amount: numbe
|
|
|
78
77
|
* ); // => [3, 4, 5], array becomes [1, 2]
|
|
79
78
|
* ```
|
|
80
79
|
*/
|
|
81
|
-
export declare function splice<Item>(array: Item[], start: number): Item[];
|
|
82
|
-
//#endregion
|
|
80
|
+
export declare function splice<Item>(array: Item[], start: number): Item[];
|
package/dist/array/splice.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ARRAY_INSERT_TYPE_SPLICE } from "../models/array/array.misc.model.mjs";
|
|
2
1
|
import { insertValues } from "../internal/array/insert.mjs";
|
|
3
|
-
|
|
2
|
+
import { ARRAY_INSERT_TYPE_SPLICE } from "../models/array/array.misc.model.mjs";
|
|
3
|
+
// src/array/splice.ts
|
|
4
4
|
function splice(array, start, deleteCountOrItems, items) {
|
|
5
5
|
const deleteCountIsNumber = typeof deleteCountOrItems === "number";
|
|
6
6
|
return insertValues(ARRAY_INSERT_TYPE_SPLICE, array, deleteCountIsNumber ? items : deleteCountOrItems, start, deleteCountIsNumber ? deleteCountOrItems : 0);
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { splice };
|
package/dist/array/swap.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/swap.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Swap two smaller arrays within a larger array
|
|
5
4
|
*
|
|
@@ -182,5 +181,4 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
|
|
|
182
181
|
export declare namespace swap {
|
|
183
182
|
export var indices: typeof swapIndices;
|
|
184
183
|
}
|
|
185
|
-
//#endregion
|
|
186
184
|
export {};
|
package/dist/array/swap.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getArrayCallback } from "../internal/array/callbacks.mjs";
|
|
2
|
+
import { indexOf } from "../internal/array/index-of.mjs";
|
|
2
3
|
import { indexOfArray } from "../internal/array/match.mjs";
|
|
3
4
|
import { arraysOverlap } from "../internal/array/overlap.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/array/swap.ts
|
|
5
|
+
// src/array/swap.ts
|
|
6
6
|
function swap(array, first, second, third) {
|
|
7
7
|
if (!Array.isArray(array)) return [];
|
|
8
8
|
if (array.length === 0) return array;
|
|
@@ -58,5 +58,4 @@ function swapValues(array, from, to, key) {
|
|
|
58
58
|
return swapIndices(array, first, second);
|
|
59
59
|
}
|
|
60
60
|
swap.indices = swapIndices;
|
|
61
|
-
//#endregion
|
|
62
61
|
export { swap };
|
package/dist/array/to-map.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/to-map.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Create a _Map_ from an array of items using a specific key
|
|
5
4
|
*
|
|
@@ -92,5 +91,4 @@ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key
|
|
|
92
91
|
export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
|
|
93
92
|
export declare namespace toMap {
|
|
94
93
|
export var arrays: typeof toMapArrays;
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
94
|
+
}
|
package/dist/array/to-map.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getArrayCallbacks } from "../internal/array/callbacks.mjs";
|
|
2
|
-
|
|
2
|
+
// src/array/to-map.ts
|
|
3
3
|
function getMapValues(array, first, second, arrays) {
|
|
4
4
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
|
|
5
5
|
const { length } = array;
|
|
@@ -24,5 +24,4 @@ function toMapArrays(array, first, second) {
|
|
|
24
24
|
return getMapValues(array, first, second, true);
|
|
25
25
|
}
|
|
26
26
|
toMap.arrays = toMapArrays;
|
|
27
|
-
//#endregion
|
|
28
27
|
export { toMap, toMapArrays };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/to-record.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Create a record from an array of items using a specific key
|
|
5
4
|
*
|
|
@@ -92,5 +91,4 @@ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item,
|
|
|
92
91
|
export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
93
92
|
export declare namespace toRecord {
|
|
94
93
|
export var arrays: typeof toRecordArrays;
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
94
|
+
}
|
package/dist/array/to-record.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { groupValues } from "../internal/array/group.mjs";
|
|
2
|
-
|
|
2
|
+
// src/array/to-record.ts
|
|
3
3
|
function toRecord(array, first, second) {
|
|
4
4
|
return groupValues(array, first, second, false);
|
|
5
5
|
}
|
|
@@ -7,5 +7,4 @@ function toRecordArrays(array, first, second) {
|
|
|
7
7
|
return groupValues(array, first, second, true);
|
|
8
8
|
}
|
|
9
9
|
toRecord.arrays = toRecordArrays;
|
|
10
|
-
//#endregion
|
|
11
10
|
export { toRecord, toRecordArrays };
|
package/dist/array/to-set.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/to-set.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Create a _Set_ from an array of items using a callback
|
|
5
4
|
*
|
|
@@ -43,5 +42,4 @@ export declare function toSet<Item extends PlainObject, ItemKey extends keyof It
|
|
|
43
42
|
* toSet([1, 2, 3]); // => Set { 1, 2, 3 }
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
export declare function toSet<Item>(array: Item[]): Set<Item>;
|
|
47
|
-
//#endregion
|
|
45
|
+
export declare function toSet<Item>(array: Item[]): Set<Item>;
|
package/dist/array/to-set.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getArrayCallbacks } from "../internal/array/callbacks.mjs";
|
|
2
|
-
|
|
2
|
+
// src/array/to-set.ts
|
|
3
3
|
function toSet(array, value) {
|
|
4
4
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
|
|
5
5
|
const callbacks = getArrayCallbacks(void 0, void 0, value);
|
|
@@ -9,5 +9,4 @@ function toSet(array, value) {
|
|
|
9
9
|
for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
|
|
10
10
|
return set;
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { toSet };
|
package/dist/array/toggle.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/toggle.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Toggle an item in an array
|
|
5
4
|
*
|
|
@@ -57,5 +56,4 @@ export declare function toggle<Item extends PlainObject, ItemKey extends keyof I
|
|
|
57
56
|
* ); // => [1, 3, 4]
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
export declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
|
|
61
|
-
//#endregion
|
|
59
|
+
export declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
|
package/dist/array/toggle.mjs
CHANGED
package/dist/array/union.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/array/union.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Get the combined, unique values from two arrays
|
|
4
3
|
*
|
|
@@ -50,5 +49,4 @@ export declare function union<First extends Record<string, unknown>, Second exte
|
|
|
50
49
|
* ); // => [1, 2, 3, 4]
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
53
|
-
export declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
|
|
54
|
-
//#endregion
|
|
52
|
+
export declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
|
package/dist/array/union.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ARRAY_SETS_COMPARE_UNION } from "../models/array/array.misc.model.mjs";
|
|
2
1
|
import { compareSets } from "../internal/array/sets.mjs";
|
|
3
|
-
|
|
2
|
+
import { ARRAY_SETS_COMPARE_UNION } from "../models/array/array.misc.model.mjs";
|
|
3
|
+
// src/array/union.ts
|
|
4
4
|
function union(first, second, key) {
|
|
5
5
|
return compareSets(ARRAY_SETS_COMPARE_UNION, first, second, key);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { union };
|
package/dist/array/unique.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/unique.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Get an array of unique items
|
|
5
4
|
*
|
|
@@ -43,5 +42,4 @@ export declare function unique<Item extends PlainObject, ItemKey extends keyof I
|
|
|
43
42
|
* unique([1, 2, 3, 2]); // => [1, 2, 3]
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
export declare function unique<Item>(array: Item[]): Item[];
|
|
47
|
-
//#endregion
|
|
45
|
+
export declare function unique<Item>(array: Item[]): Item[];
|
package/dist/array/unique.mjs
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { getArrayCallback } from "../internal/array/callbacks.mjs";
|
|
2
|
+
import "../models/array/array.misc.model.mjs";
|
|
3
|
+
// src/array/unique.ts
|
|
4
4
|
function unique(array, key) {
|
|
5
5
|
if (!Array.isArray(array)) return [];
|
|
6
|
-
|
|
6
|
+
const { length } = array;
|
|
7
|
+
if (length < 2) return array.slice();
|
|
8
|
+
const callback = getArrayCallback(key);
|
|
9
|
+
if (callback == null && length >= 100) return [...new Set(array)];
|
|
10
|
+
const keyed = /* @__PURE__ */ new Set();
|
|
11
|
+
const uniques = [];
|
|
12
|
+
for (let index = 0; index < length; index += 1) {
|
|
13
|
+
const item = array[index];
|
|
14
|
+
const value = callback == null ? item : callback(item, index, array);
|
|
15
|
+
if (!keyed.has(value)) {
|
|
16
|
+
keyed.add(value);
|
|
17
|
+
uniques.push(item);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return uniques;
|
|
7
21
|
}
|
|
8
|
-
//#endregion
|
|
9
22
|
export { unique };
|
package/dist/array/update.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
|
-
//#region src/array/update.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Update an item in an array
|
|
5
4
|
*
|
|
@@ -57,5 +56,4 @@ export declare function update<Item extends PlainObject, ItemKey extends keyof I
|
|
|
57
56
|
* ); // => [1, 2, 3, 4]
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
export declare function update<Item>(destination: Item[], updated: Item[]): Item[];
|
|
61
|
-
//#endregion
|
|
59
|
+
export declare function update<Item>(destination: Item[], updated: Item[]): Item[];
|
package/dist/array/update.mjs
CHANGED
package/dist/beacon.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function Beacon(this: any, value: unknown, options?: BeaconOptions<unknown>): void;
|
|
5
|
-
declare function Observable(this: any, beacon: BeaconState<unknown>): void;
|
|
1
|
+
import { Beacon, BeaconOptions, BeaconState, InternalBeacon, InternalObservable, Observable, Observer } from "./models/beacon.model.mjs";
|
|
2
|
+
declare function Beacon(this: InternalBeacon, value: unknown, options?: BeaconOptions<unknown>): void;
|
|
3
|
+
declare function Observable(this: InternalObservable, beacon: BeaconState<unknown>): void;
|
|
6
4
|
/**
|
|
7
5
|
* Create a new beacon
|
|
8
6
|
*
|
|
@@ -18,13 +16,6 @@ export declare function beacon<Value>(value: Value, options?: BeaconOptions<Valu
|
|
|
18
16
|
* @returns `true` if the value is a beacon, otherwise `false`
|
|
19
17
|
*/
|
|
20
18
|
export declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
|
|
21
|
-
/**
|
|
22
|
-
* Is the value a beacon subscription?
|
|
23
|
-
*
|
|
24
|
-
* @param value Value to check
|
|
25
|
-
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
26
|
-
*/
|
|
27
|
-
export declare function isBeaconSubscription(value: unknown): value is Subscription;
|
|
28
19
|
/**
|
|
29
20
|
* Is the value an observable?
|
|
30
21
|
*
|
|
@@ -32,5 +23,4 @@ export declare function isBeaconSubscription(value: unknown): value is Subscript
|
|
|
32
23
|
* @returns `true` if the value is an observable, otherwise `false`
|
|
33
24
|
*/
|
|
34
25
|
export declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
|
|
35
|
-
//#endregion
|
|
36
26
|
export type { Beacon, BeaconOptions, Observable, Observer };
|
package/dist/beacon.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { noop } from "./internal/function/misc.mjs";
|
|
2
2
|
import { isPlainObject } from "./internal/is.mjs";
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
//#region src/beacon.ts
|
|
3
|
+
import { subscriptions } from "./internal/subscription.mjs";
|
|
4
|
+
import { BEACON_MESSAGE_RETRIEVE, BEACON_MESSAGE_SUBSCRIBE, BEACON_NAME, BEACON_OBSERVABLE, BEACON_SYMBOL, BEACON_TYPE_ERROR, BEACON_TYPE_NEXT } from "./models/beacon.model.mjs";
|
|
5
|
+
// src/beacon.ts
|
|
7
6
|
function Beacon(value, options) {
|
|
8
7
|
this[BEACON_SYMBOL] = {
|
|
9
8
|
value,
|
|
10
9
|
active: true,
|
|
11
|
-
options: createBeaconOptions(options)
|
|
10
|
+
options: createBeaconOptions(options),
|
|
11
|
+
name: BEACON_NAME
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
Beacon.prototype[BEACON_PROPERTY] = BEACON_NAME;
|
|
15
14
|
Beacon.prototype.deactivate = deactivateBeacon;
|
|
16
15
|
Beacon.prototype.emit = emitBeaconValue;
|
|
17
16
|
Beacon.prototype.error = emitBeaconError;
|
|
@@ -33,10 +32,10 @@ Object.defineProperties(Beacon.prototype, {
|
|
|
33
32
|
function Observable(beacon) {
|
|
34
33
|
this[BEACON_SYMBOL] = {
|
|
35
34
|
beacon,
|
|
36
|
-
active: beacon.active
|
|
35
|
+
active: beacon.active,
|
|
36
|
+
name: BEACON_OBSERVABLE
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
40
39
|
Observable.prototype.deactivate = deactivateObservable;
|
|
41
40
|
Observable.prototype.subscribe = subscribeToObservable;
|
|
42
41
|
Object.defineProperty(Observable.prototype, "active", {
|
|
@@ -127,16 +126,7 @@ function isBeacon(value) {
|
|
|
127
126
|
return isBeaconInstance(BEACON_NAME, value);
|
|
128
127
|
}
|
|
129
128
|
function isBeaconInstance(name, value) {
|
|
130
|
-
return typeof value === "object" && value !== null &&
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Is the value a beacon subscription?
|
|
134
|
-
*
|
|
135
|
-
* @param value Value to check
|
|
136
|
-
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
137
|
-
*/
|
|
138
|
-
function isBeaconSubscription(value) {
|
|
139
|
-
return isSubscription(value) && value["$beacon"] === "subscription";
|
|
129
|
+
return typeof value === "object" && value !== null && BEACON_SYMBOL in value && value[BEACON_SYMBOL].name === name;
|
|
140
130
|
}
|
|
141
131
|
/**
|
|
142
132
|
* Is the value an observable?
|
|
@@ -150,7 +140,7 @@ function isObservable(value) {
|
|
|
150
140
|
function subscribeToObservable(first, second, third) {
|
|
151
141
|
const state = this[BEACON_SYMBOL];
|
|
152
142
|
if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
|
|
153
|
-
state.beacon.subscriptions ??= subscriptions(
|
|
143
|
+
state.beacon.subscriptions ??= subscriptions();
|
|
154
144
|
const observer = createObserver(first, second, third);
|
|
155
145
|
const [subscription] = state.beacon.subscriptions.create({
|
|
156
146
|
isActive: () => state.beacon.active && state.active,
|
|
@@ -170,5 +160,4 @@ function updateBeacon(instance, type, value, finish) {
|
|
|
170
160
|
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
171
161
|
if (finish === true) closeBeacon(state, true);
|
|
172
162
|
}
|
|
173
|
-
|
|
174
|
-
export { beacon, isBeacon, isBeaconSubscription, isObservable };
|
|
163
|
+
export { beacon, isBeacon, isObservable };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { SubscriptionProperty } from "../models/subscription.model.mjs";
|
|
2
1
|
import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models/color.model.mjs";
|
|
3
|
-
//#region src/color/constants.d.ts
|
|
4
2
|
type ColorTypes = {
|
|
5
3
|
all: Set<"alpha" | ColorTypeExtended>;
|
|
6
4
|
hex: "hex";
|
|
@@ -39,9 +37,7 @@ export declare const COLOR_MAX: {
|
|
|
39
37
|
hex: number;
|
|
40
38
|
percent: number;
|
|
41
39
|
};
|
|
42
|
-
export declare const
|
|
43
|
-
export declare const COLOR_PROPERTY = "$color";
|
|
44
|
-
export declare const COLOR_SYMBOL: symbol;
|
|
40
|
+
export declare const COLOR_SYMBOL: unique symbol;
|
|
45
41
|
export declare const COLOR_TYPE: ColorTypes;
|
|
46
42
|
export declare const COLOR_SRGB: {
|
|
47
43
|
luminanceBlue: number;
|
|
@@ -54,6 +50,4 @@ export declare const COLOR_SRGB: {
|
|
|
54
50
|
luminanceRed: number;
|
|
55
51
|
luminanceThreshold: number;
|
|
56
52
|
};
|
|
57
|
-
export declare const colorSubscription: SubscriptionProperty;
|
|
58
|
-
//#endregion
|
|
59
53
|
export {};
|
package/dist/color/constants.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/color/constants.ts
|
|
1
|
+
// src/color/constants.ts
|
|
3
2
|
const COLOR_ALPHA = {
|
|
4
3
|
fullHexShort: "f",
|
|
5
4
|
fullHexLong: "ff",
|
|
@@ -68,9 +67,7 @@ const COLOR_MAX = {
|
|
|
68
67
|
hex: 255,
|
|
69
68
|
percent: 100
|
|
70
69
|
};
|
|
71
|
-
const
|
|
72
|
-
const COLOR_PROPERTY = "$color";
|
|
73
|
-
const COLOR_SYMBOL = Symbol(COLOR_PROPERTY);
|
|
70
|
+
const COLOR_SYMBOL = Symbol("color");
|
|
74
71
|
const COLOR_TYPE = {
|
|
75
72
|
all: void 0,
|
|
76
73
|
hex: "hex",
|
|
@@ -105,9 +102,4 @@ const COLOR_SRGB = {
|
|
|
105
102
|
luminanceRed: .2126,
|
|
106
103
|
luminanceThreshold: .625
|
|
107
104
|
};
|
|
108
|
-
|
|
109
|
-
key: COLOR_PROPERTY,
|
|
110
|
-
value: SUBSCRIPTION_NAME
|
|
111
|
-
};
|
|
112
|
-
//#endregion
|
|
113
|
-
export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_NAME, COLOR_PROPERTY, COLOR_SRGB, COLOR_SYMBOL, COLOR_TYPE, colorSubscription };
|
|
105
|
+
export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_SRGB, COLOR_SYMBOL, COLOR_TYPE };
|
package/dist/color/index.d.mts
CHANGED
|
@@ -5,7 +5,6 @@ import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, h
|
|
|
5
5
|
import { hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba } from "./space/hsl.mjs";
|
|
6
6
|
import { hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba } from "./space/hwb.mjs";
|
|
7
7
|
import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.mjs";
|
|
8
|
-
//#region src/color/index.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Get a _Color_ from any kind of value
|
|
11
10
|
*
|
|
@@ -16,5 +15,4 @@ import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.
|
|
|
16
15
|
* @returns _Color_ instance
|
|
17
16
|
*/
|
|
18
17
|
export declare function getColor(value: unknown): Color;
|
|
19
|
-
//#endregion
|
|
20
18
|
export { type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, type RGBAColor, type RGBColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
|
package/dist/color/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { color } from "./instance.mjs";
|
|
2
2
|
import { isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor } from "./misc/is.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
|
|
4
4
|
import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
|
|
5
5
|
import { hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba } from "./space/hsl.mjs";
|
|
6
6
|
import { hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba } from "./space/hwb.mjs";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.mjs";
|
|
8
|
+
// src/color/index.ts
|
|
9
9
|
/**
|
|
10
10
|
* Get a _Color_ from any kind of value
|
|
11
11
|
*
|
|
@@ -18,5 +18,4 @@ import { color } from "./instance.mjs";
|
|
|
18
18
|
function getColor(value) {
|
|
19
19
|
return isColor(value) ? value : color(value);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
|
package/dist/color/instance.mjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { herald } from "../internal/herald.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { COLOR_SYMBOL, COLOR_TYPE } from "./constants.mjs";
|
|
3
3
|
import { getColorAlpha, setColorAlpha } from "./misc/alpha.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { formatHexColor, formatHslColor, formatHwbColor, formatRgbColor } from "./misc/format.mjs";
|
|
5
|
+
import { getColorState } from "./misc/state.mjs";
|
|
5
6
|
import { getHexColor, getHexaColor, setHexValue, setHexaValue } from "./space/hex.mjs";
|
|
6
7
|
import { getHslValue, getHslaValue, setHslValue, setHslaValue } from "./space/hsl.mjs";
|
|
7
8
|
import { getHwbValue, getHwbaValue, setHwbValue, setHwbaValue } from "./space/hwb.mjs";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
//#region src/color/instance.ts
|
|
9
|
+
import { getRgbColor, getRgbaColor, setRgbValue, setRgbaValue } from "./space/rgb.mjs";
|
|
10
|
+
// src/color/instance.ts
|
|
11
11
|
function Color(value) {
|
|
12
12
|
this[COLOR_SYMBOL] = {
|
|
13
13
|
changes: herald({
|
|
14
14
|
names: [COLOR_TYPE.wildcard, ...COLOR_TYPE.all],
|
|
15
|
-
property: colorSubscription,
|
|
16
15
|
onCreate: (event, callback) => onCreateSubscription(this, event, callback)
|
|
17
16
|
}),
|
|
18
17
|
values: getColorState(value)
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
Color.prototype[COLOR_PROPERTY] = COLOR_NAME;
|
|
22
20
|
Color.prototype.subscribe = subscribeToColor;
|
|
23
21
|
Color.prototype.toHexString = formatHexColor;
|
|
24
22
|
Color.prototype.toHslString = formatHslColor;
|
|
@@ -103,5 +101,4 @@ function subscribeToColor(callback, signal) {
|
|
|
103
101
|
function unsubscribeFromColor() {
|
|
104
102
|
this[COLOR_SYMBOL].changes.clear();
|
|
105
103
|
}
|
|
106
|
-
//#endregion
|
|
107
104
|
export { color };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Alpha, InternalColor } from "../../models/color.model.mjs";
|
|
2
|
-
//#region src/color/misc/alpha.d.ts
|
|
3
2
|
export declare function getAlpha(value: unknown, hex: boolean): Alpha;
|
|
4
3
|
export declare function getColorAlpha(this: InternalColor): number;
|
|
5
4
|
export declare function getAlphaHexadecimal(value: number): string;
|
|
6
5
|
export declare function getAlphaValue(original: number): number;
|
|
7
|
-
export declare function setColorAlpha(this: InternalColor, value: unknown): void;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function setColorAlpha(this: InternalColor, value: unknown): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { round } from "../../internal/math/misc.mjs";
|
|
2
2
|
import { clamp } from "../../internal/number.mjs";
|
|
3
3
|
import { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_MAX, COLOR_SYMBOL } from "../constants.mjs";
|
|
4
|
-
|
|
4
|
+
// src/color/misc/alpha.ts
|
|
5
5
|
function getAlpha(value, hex) {
|
|
6
6
|
if (typeof value === "number") return getAlphaFromValue(value);
|
|
7
7
|
if (typeof value !== "string" || value.toLowerCase() === COLOR_ALPHA.fullHexLong) return { ...COLOR_DEFAULTS.alpha };
|
|
@@ -33,5 +33,4 @@ function getAlphaValue(original) {
|
|
|
33
33
|
function setColorAlpha(value) {
|
|
34
34
|
if (typeof value === "number" && !Number.isNaN(value)) this[COLOR_SYMBOL].values.alpha = getAlpha(value, false);
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
export { getAlpha, getAlphaHexadecimal, getAlphaValue, getColorAlpha, setColorAlpha };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { InternalColor } from "../../models/color.model.mjs";
|
|
2
|
-
//#region src/color/misc/format.d.ts
|
|
3
2
|
export declare function formatHexColor(this: InternalColor, alpha?: boolean): string;
|
|
4
3
|
export declare function formatHslColor(this: InternalColor, alpha?: boolean): string;
|
|
5
4
|
export declare function formatHwbColor(this: InternalColor, alpha?: boolean): string;
|
|
6
|
-
export declare function formatRgbColor(this: InternalColor, alpha?: boolean): string;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare function formatRgbColor(this: InternalColor, alpha?: boolean): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COLOR_SYMBOL, COLOR_TYPE } from "../constants.mjs";
|
|
2
2
|
import { getColorFromState } from "./state.mjs";
|
|
3
|
-
|
|
3
|
+
// src/color/misc/format.ts
|
|
4
4
|
function formatHexColor(alpha) {
|
|
5
5
|
return `#${alpha === true ? this.hexa : this.hex}`;
|
|
6
6
|
}
|
|
@@ -22,5 +22,4 @@ function formatRgbColor(alpha) {
|
|
|
22
22
|
function getSuffix(state, alpha) {
|
|
23
23
|
return alpha === true ? ` / ${state.alpha.value}%` : "";
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { formatHexColor, formatHslColor, formatHwbColor, formatRgbColor };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
|
-
//#region src/color/misc/get.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Get a foreground color _(usually text)_ based on a background color's luminance as an unprefixed hex color string
|
|
5
4
|
*
|
|
@@ -102,5 +101,4 @@ export declare function getRgbaColor(value: unknown): RGBAColor;
|
|
|
102
101
|
* @param value Original value
|
|
103
102
|
* @returns _RGB_ color
|
|
104
103
|
*/
|
|
105
|
-
export declare function getRgbColor(value: unknown): RGBColor;
|
|
106
|
-
//#endregion
|
|
104
|
+
export declare function getRgbColor(value: unknown): RGBColor;
|
package/dist/color/misc/get.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { round } from "../../internal/math/misc.mjs";
|
|
2
2
|
import { clamp } from "../../internal/number.mjs";
|
|
3
3
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_SRGB, COLOR_TYPE } from "../constants.mjs";
|
|
4
|
-
import { getColorFromState, getColorState } from "./state.mjs";
|
|
5
4
|
import { color } from "../instance.mjs";
|
|
6
|
-
|
|
5
|
+
import { getColorFromState, getColorState } from "./state.mjs";
|
|
6
|
+
// src/color/misc/get.ts
|
|
7
7
|
function getClampedValue(value, minimum, maximum, rounding) {
|
|
8
8
|
if (typeof value !== "number" || Number.isNaN(value)) return minimum;
|
|
9
9
|
const actual = rounding ?? false ? round(value) : value;
|
|
@@ -143,5 +143,4 @@ function getRgbaColor(value) {
|
|
|
143
143
|
function getRgbColor(value) {
|
|
144
144
|
return getColorFromState(getColorState(value), COLOR_TYPE.rgb);
|
|
145
145
|
}
|
|
146
|
-
//#endregion
|
|
147
146
|
export { getDegrees, getForegroundColor, getHexColor, getHexValue, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getPercentage, getRgbColor, getRgbaColor };
|
package/dist/color/misc/is.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Subscription } from "../../models/subscription.model.mjs";
|
|
2
1
|
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
3
|
-
//#region src/color/misc/is.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* Is the value a _Color_?
|
|
6
4
|
*
|
|
@@ -8,13 +6,6 @@ import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor }
|
|
|
8
6
|
* @returns `true` if the value is a _Color_, otherwise `false`
|
|
9
7
|
*/
|
|
10
8
|
export declare function isColor(value: unknown): value is Color;
|
|
11
|
-
/**
|
|
12
|
-
* Is the value a color subscription?
|
|
13
|
-
*
|
|
14
|
-
* @param value Value to check
|
|
15
|
-
* @returns `true` if the value is a color subscription, otherwise `false`
|
|
16
|
-
*/
|
|
17
|
-
export declare function isColorSubscription(value: unknown): value is Subscription;
|
|
18
9
|
/**
|
|
19
10
|
* Is the value a hex color?
|
|
20
11
|
*
|
|
@@ -79,5 +70,4 @@ export declare function isRgbaLike(value: unknown): value is Record<keyof RGBACo
|
|
|
79
70
|
* @returns `true` if the value is an _RGB_ color, otherwise `false`
|
|
80
71
|
*/
|
|
81
72
|
export declare function isRgbColor(value: unknown): value is RGBColor;
|
|
82
|
-
export declare function isRgbLike(value: unknown): value is Record<keyof RGBColor, unknown>;
|
|
83
|
-
//#endregion
|
|
73
|
+
export declare function isRgbLike(value: unknown): value is Record<keyof RGBColor, unknown>;
|