@oscarpalmer/atoms 0.194.0 → 0.195.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/index.d.mts +2 -2
- package/dist/array/index.mjs +2 -2
- package/dist/array/move.mjs +1 -1
- package/dist/array/swap.mjs +1 -1
- package/dist/color/instance.mjs +1 -1
- package/dist/color/misc/state.d.mts +1 -1
- package/dist/color/models.d.mts +1 -1
- package/dist/color/space/hex.mjs +1 -1
- package/dist/color/space/rgb.mjs +1 -1
- package/dist/function/index.d.mts +1 -2
- package/dist/function/index.mjs +1 -2
- package/dist/function/once.mjs +1 -1
- package/dist/herald.d.mts +2 -71
- package/dist/herald.mjs +1 -109
- package/dist/index.d.mts +3270 -3271
- package/dist/index.mjs +1500 -1498
- package/dist/{array → internal/array}/get.d.mts +2 -2
- package/dist/{array → internal/array}/get.mjs +2 -2
- package/dist/{array → internal/array}/match.d.mts +2 -2
- package/dist/{array → internal/array}/match.mjs +2 -2
- package/dist/internal/defaults.d.mts +5 -0
- package/dist/internal/defaults.mjs +9 -0
- package/dist/{function → internal/function}/assert.d.mts +2 -2
- package/dist/{function → internal/function}/assert.mjs +2 -2
- package/dist/{function → internal/function}/memoize.d.mts +2 -2
- package/dist/{function → internal/function}/memoize.mjs +3 -3
- package/dist/{function → internal/function}/work.d.mts +2 -2
- package/dist/{function → internal/function}/work.mjs +2 -2
- package/dist/internal/herald.d.mts +71 -0
- package/dist/internal/herald.mjs +110 -0
- package/dist/internal/number.d.mts +1 -2
- package/dist/internal/number.mjs +1 -4
- package/dist/internal/{result.d.mts → result/misc.d.mts} +42 -3
- package/dist/internal/{result.mjs → result/misc.mjs} +29 -3
- package/dist/{result → internal/result}/models.d.mts +2 -2
- package/dist/{sized → internal/sized}/map.d.mts +1 -1
- package/dist/{sized → internal/sized}/map.mjs +2 -2
- package/dist/internal/{sized.d.mts → sized/misc.d.mts} +1 -1
- package/dist/internal/{sized.mjs → sized/misc.mjs} +2 -2
- package/dist/{string → internal/string}/case.d.mts +1 -1
- package/dist/{string → internal/string}/case.mjs +2 -2
- package/dist/internal/{string.d.mts → string/misc.d.mts} +1 -1
- package/dist/internal/{string.mjs → string/misc.mjs} +1 -1
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/has.d.mts +1 -1
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +2 -2
- package/dist/is.mjs +2 -2
- package/dist/logger.mjs +1 -1
- package/dist/promise/helpers.d.mts +1 -1
- package/dist/promise/helpers.mjs +2 -2
- package/dist/promise/index.d.mts +1 -1
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/misc.mjs +2 -1
- package/dist/promise/models.d.mts +1 -1
- package/dist/query.mjs +1 -1
- package/dist/queue.mjs +1 -4
- package/dist/random.mjs +1 -1
- package/dist/result/index.d.mts +1 -1
- package/dist/result/index.mjs +1 -1
- package/dist/result/match.d.mts +1 -1
- package/dist/result/match.mjs +1 -1
- package/dist/result/misc.d.mts +3 -42
- package/dist/result/misc.mjs +2 -28
- package/dist/result/work/flow.d.mts +1 -1
- package/dist/result/work/flow.mjs +2 -2
- package/dist/result/work/pipe.d.mts +1 -1
- package/dist/result/work/pipe.mjs +2 -2
- package/dist/sized/set.mjs +1 -1
- package/dist/string/fuzzy.mjs +2 -2
- package/dist/string/index.d.mts +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/string/match.mjs +1 -1
- package/dist/string/normalize.mjs +2 -2
- package/dist/string/template.mjs +1 -1
- package/dist/subscription.d.mts +2 -0
- package/dist/subscription.mjs +2 -0
- package/dist/value/diff.mjs +1 -1
- package/dist/value/smush.mjs +1 -1
- package/package.json +23 -11
- /package/dist/{result → internal/result}/models.mjs +0 -0
package/dist/array/index.d.mts
CHANGED
|
@@ -3,15 +3,15 @@ import { exists } from "./exists.mjs";
|
|
|
3
3
|
import { find, findLast } from "./find.mjs";
|
|
4
4
|
import { flatten } from "./flatten.mjs";
|
|
5
5
|
import { range, times } from "./from.mjs";
|
|
6
|
-
import { getArray } from "./get.mjs";
|
|
7
6
|
import { chunk } from "../internal/array/chunk.mjs";
|
|
8
7
|
import { compact } from "../internal/array/compact.mjs";
|
|
8
|
+
import { getArray } from "../internal/array/get.mjs";
|
|
9
9
|
import { indexOf, lastIndexOf } from "../internal/array/index-of.mjs";
|
|
10
|
+
import { ArrayComparison, endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "../internal/array/match.mjs";
|
|
10
11
|
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
11
12
|
import { insert } from "./insert.mjs";
|
|
12
13
|
import { intersection } from "./intersection.mjs";
|
|
13
14
|
import { partition } from "./partition.mjs";
|
|
14
|
-
import { ArrayComparison, endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "./match.mjs";
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { reverse } from "./reverse.mjs";
|
|
17
17
|
import { select } from "./select.mjs";
|
package/dist/array/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { chunk } from "../internal/array/chunk.mjs";
|
|
2
2
|
import { compact } from "../internal/array/compact.mjs";
|
|
3
|
+
import { getArray } from "../internal/array/get.mjs";
|
|
3
4
|
import { indexOf, lastIndexOf } from "../internal/array/index-of.mjs";
|
|
5
|
+
import { endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "../internal/array/match.mjs";
|
|
4
6
|
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
5
7
|
import { difference } from "./difference.mjs";
|
|
6
8
|
import { exists } from "./exists.mjs";
|
|
7
9
|
import { find, findLast } from "./find.mjs";
|
|
8
10
|
import { flatten } from "./flatten.mjs";
|
|
9
11
|
import { range, times } from "./from.mjs";
|
|
10
|
-
import { getArray } from "./get.mjs";
|
|
11
12
|
import { insert } from "./insert.mjs";
|
|
12
13
|
import { intersection } from "./intersection.mjs";
|
|
13
14
|
import { partition } from "./partition.mjs";
|
|
14
|
-
import { endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "./match.mjs";
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { reverse } from "./reverse.mjs";
|
|
17
17
|
import { select } from "./select.mjs";
|
package/dist/array/move.mjs
CHANGED
package/dist/array/swap.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getArrayCallback } from "../internal/array/callbacks.mjs";
|
|
2
2
|
import { indexOf } from "../internal/array/index-of.mjs";
|
|
3
|
-
import { indexOfArray } from "
|
|
3
|
+
import { indexOfArray } from "../internal/array/match.mjs";
|
|
4
4
|
import { arraysOverlap } from "../internal/array/overlap.mjs";
|
|
5
5
|
//#region src/array/swap.ts
|
|
6
6
|
function swap(array, first, second, third) {
|
package/dist/color/instance.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { herald } from "../herald.mjs";
|
|
1
|
+
import { herald } from "../internal/herald.mjs";
|
|
2
2
|
import { COLOR_PROPERTY, COLOR_TYPE } from "./constants.mjs";
|
|
3
3
|
import { getAlpha } from "./misc/alpha.mjs";
|
|
4
4
|
import { getColorFromState, getColorState, setHSLColor, setHWBColor, setHexColor, setRGBColor } from "./misc/state.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Herald } from "../../herald.mjs";
|
|
1
|
+
import { Herald } from "../../internal/herald.mjs";
|
|
2
2
|
import { Color, ColorChanges, ColorState, ColorType } from "../models.mjs";
|
|
3
3
|
//#region src/color/misc/state.d.ts
|
|
4
4
|
declare function getColorFromState<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
|
package/dist/color/models.d.mts
CHANGED
package/dist/color/space/hex.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join } from "../../internal/string.mjs";
|
|
1
|
+
import { join } from "../../internal/string/misc.mjs";
|
|
2
2
|
import { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_LENGTHS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
|
|
3
3
|
import { getHexValue, getPercentage } from "../misc/get.mjs";
|
|
4
4
|
import { isHexColor } from "../misc/is.mjs";
|
package/dist/color/space/rgb.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join } from "../../internal/string.mjs";
|
|
1
|
+
import { join } from "../../internal/string/misc.mjs";
|
|
2
2
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
|
|
3
3
|
import { getAlpha, getAlphaValue } from "../misc/alpha.mjs";
|
|
4
4
|
import { getHexValue } from "../misc/get.mjs";
|
package/dist/function/index.mjs
CHANGED
package/dist/function/once.mjs
CHANGED
package/dist/herald.d.mts
CHANGED
|
@@ -1,71 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/herald.d.ts
|
|
4
|
-
type Herald<Events extends Record<string, GenericCallback>> = {
|
|
5
|
-
readonly events: HeraldEvents<Events>;
|
|
6
|
-
/**
|
|
7
|
-
* Remove all event subscribers
|
|
8
|
-
*/
|
|
9
|
-
clear(): void;
|
|
10
|
-
/**
|
|
11
|
-
* Emit an event with parameters
|
|
12
|
-
*
|
|
13
|
-
* @param event Event name
|
|
14
|
-
* @param parameters Event parameters
|
|
15
|
-
*/
|
|
16
|
-
emit<Event extends keyof Events>(event: Event, ...parameters: Parameters<Events[Event]>): void;
|
|
17
|
-
/**
|
|
18
|
-
* Is the event observed by any subscribers?
|
|
19
|
-
*
|
|
20
|
-
* @param event Event name
|
|
21
|
-
* @returns `true` if the event is observed, otherwise `false`
|
|
22
|
-
*/
|
|
23
|
-
observed<Event extends keyof Events>(event: Event): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Subscribe to an event with a callback
|
|
26
|
-
*
|
|
27
|
-
* @param event Event name
|
|
28
|
-
* @param callback Callback function
|
|
29
|
-
* @param signal Optional abort signal to cancel the subscription
|
|
30
|
-
* @returns Subscription instance
|
|
31
|
-
*/
|
|
32
|
-
subscribe<Event extends keyof Events>(event: Event, callback: Events[Event], signal?: AbortSignal): Subscription;
|
|
33
|
-
};
|
|
34
|
-
type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Key in keyof Events]: Key extends '*' ? never : (callback: Events[Key], signal?: AbortSignal) => void; };
|
|
35
|
-
type HeraldOnCreate<Events extends Record<string, GenericCallback>> = <Event extends keyof Events>(event: Event, callback: Events[Event], subscription: Subscription) => void;
|
|
36
|
-
type HeraldOptions<Events extends Record<string, GenericCallback>> = {
|
|
37
|
-
names: Array<keyof Events>;
|
|
38
|
-
property?: SubscriptionProperty;
|
|
39
|
-
onCreate?: HeraldOnCreate<Events>;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Create a _Herald_ for announcing named events
|
|
43
|
-
*
|
|
44
|
-
* @param names Event names
|
|
45
|
-
* @param property Optional property for subscription identification _(defaults to `$herald`)_
|
|
46
|
-
* @returns _Herald_ instance
|
|
47
|
-
*/
|
|
48
|
-
declare function herald<Events extends Record<string, GenericCallback>>(options: HeraldOptions<Events>): Herald<Events>;
|
|
49
|
-
/**
|
|
50
|
-
* Is the value events for a herald?
|
|
51
|
-
*
|
|
52
|
-
* @param value Value to check
|
|
53
|
-
* @returns `true` if the value is events for a herald, otherwise `false`
|
|
54
|
-
*/
|
|
55
|
-
declare function isHeraldEvents<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is HeraldEvents<Events>;
|
|
56
|
-
/**
|
|
57
|
-
* Is the value a herald?
|
|
58
|
-
*
|
|
59
|
-
* @param value Value to check
|
|
60
|
-
* @returns `true` if the value is a herald, otherwise `false`
|
|
61
|
-
*/
|
|
62
|
-
declare function isHerald<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Herald<Events>;
|
|
63
|
-
/**
|
|
64
|
-
* Is the value a herald subscription?
|
|
65
|
-
*
|
|
66
|
-
* @param value Value to check
|
|
67
|
-
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
68
|
-
*/
|
|
69
|
-
declare function isHeraldSubscription(value: unknown): value is Subscription;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { Herald, HeraldEvents, HeraldOptions, herald, isHerald, isHeraldEvents, isHeraldSubscription };
|
|
1
|
+
import { herald, isHerald, isHeraldEvents, isHeraldSubscription } from "./internal/herald.mjs";
|
|
2
|
+
export { herald, isHerald, isHeraldEvents, isHeraldSubscription };
|
package/dist/herald.mjs
CHANGED
|
@@ -1,110 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createSubscriptions, isSubscription } from "./internal/subscription.mjs";
|
|
3
|
-
//#region src/herald.ts
|
|
4
|
-
function createEvents(herald, state) {
|
|
5
|
-
const events = {};
|
|
6
|
-
Object.defineProperty(events, HERALD_PROPERTY, { value: HERALD_NAME_EVENTS });
|
|
7
|
-
for (const key of state.keys) events[key] = (callback, signal) => herald.subscribe(key, callback, signal);
|
|
8
|
-
return Object.freeze(events);
|
|
9
|
-
}
|
|
10
|
-
function emitForHerald(state, event, ...parameters) {
|
|
11
|
-
const items = state.subscriptions.state.values.from.keyed?.get(event);
|
|
12
|
-
if (items == null || items.size === 0) return;
|
|
13
|
-
for (const [callback] of items) callback(...parameters);
|
|
14
|
-
}
|
|
15
|
-
function getHeraldSubscriptionProperty(input) {
|
|
16
|
-
if (input == null) return heraldSubscription;
|
|
17
|
-
const property = isPlainObject(input) ? input : {};
|
|
18
|
-
if (typeof property.key !== "string" || property.value != null && typeof property.value !== "string") throw new Error(HERALD_MESSAGE_PROPERTY);
|
|
19
|
-
return {
|
|
20
|
-
key: property.key,
|
|
21
|
-
value: property.value
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function getHeraldState(input) {
|
|
25
|
-
const options = isPlainObject(input) ? input : {};
|
|
26
|
-
if (!Array.isArray(options.names) || options.names.length === 0 || !options.names.every((name) => typeof name === "string")) throw new Error(HERALD_MESSAGE_ARRAY);
|
|
27
|
-
if (options.onCreate != null && typeof options.onCreate !== "function") throw new Error(HERALD_MESSAGE_ONCREATE);
|
|
28
|
-
const keys = new Set(options.names);
|
|
29
|
-
const property = getHeraldSubscriptionProperty(options.property);
|
|
30
|
-
return {
|
|
31
|
-
keys,
|
|
32
|
-
subscriptions: createSubscriptions({
|
|
33
|
-
keys,
|
|
34
|
-
property
|
|
35
|
-
}),
|
|
36
|
-
onCreate: options.onCreate
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a _Herald_ for announcing named events
|
|
41
|
-
*
|
|
42
|
-
* @param names Event names
|
|
43
|
-
* @param property Optional property for subscription identification _(defaults to `$herald`)_
|
|
44
|
-
* @returns _Herald_ instance
|
|
45
|
-
*/
|
|
46
|
-
function herald(options) {
|
|
47
|
-
const state = getHeraldState(options);
|
|
48
|
-
const instance = {
|
|
49
|
-
clear: () => state.subscriptions.clear(),
|
|
50
|
-
emit: (event, ...parameters) => emitForHerald(state, event, ...parameters),
|
|
51
|
-
observed: (event) => (state.subscriptions.state.items.keyed?.get(event)?.size ?? 0) > 0,
|
|
52
|
-
subscribe: (key, callback, signal) => subscribeToHerald(state, key, callback, signal)
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperties(instance, {
|
|
55
|
-
[HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
|
|
56
|
-
events: {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
value: createEvents(instance, state)
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return Object.freeze(instance);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Is the value events for a herald?
|
|
65
|
-
*
|
|
66
|
-
* @param value Value to check
|
|
67
|
-
* @returns `true` if the value is events for a herald, otherwise `false`
|
|
68
|
-
*/
|
|
69
|
-
function isHeraldEvents(value) {
|
|
70
|
-
return isHeraldInstance(HERALD_NAME_EVENTS, value);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Is the value a herald?
|
|
74
|
-
*
|
|
75
|
-
* @param value Value to check
|
|
76
|
-
* @returns `true` if the value is a herald, otherwise `false`
|
|
77
|
-
*/
|
|
78
|
-
function isHerald(value) {
|
|
79
|
-
return isHeraldInstance(HERALD_NAME_HERALD, value);
|
|
80
|
-
}
|
|
81
|
-
function isHeraldInstance(name, value) {
|
|
82
|
-
return isPlainObject(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Is the value a herald subscription?
|
|
86
|
-
*
|
|
87
|
-
* @param value Value to check
|
|
88
|
-
* @returns `true` if the value is a herald subscription, otherwise `false`
|
|
89
|
-
*/
|
|
90
|
-
function isHeraldSubscription(value) {
|
|
91
|
-
return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
|
|
92
|
-
}
|
|
93
|
-
function subscribeToHerald(state, key, callback, signal) {
|
|
94
|
-
const [subscription, existing] = state.subscriptions.create({
|
|
95
|
-
key,
|
|
96
|
-
signal,
|
|
97
|
-
value: callback
|
|
98
|
-
});
|
|
99
|
-
if (!existing) state.onCreate?.(key, callback, subscription);
|
|
100
|
-
return subscription;
|
|
101
|
-
}
|
|
102
|
-
const HERALD_PROPERTY = "$herald";
|
|
103
|
-
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
104
|
-
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
105
|
-
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
106
|
-
const HERALD_NAME_EVENTS = "events";
|
|
107
|
-
const HERALD_NAME_HERALD = "herald";
|
|
108
|
-
const heraldSubscription = { key: HERALD_PROPERTY };
|
|
109
|
-
//#endregion
|
|
1
|
+
import { herald, isHerald, isHeraldEvents, isHeraldSubscription } from "./internal/herald.mjs";
|
|
110
2
|
export { herald, isHerald, isHeraldEvents, isHeraldSubscription };
|