@oscarpalmer/atoms 0.203.0 → 0.204.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/filter.mjs +0 -1
- package/dist/array/find.mjs +0 -1
- package/dist/array/first.mjs +0 -1
- package/dist/array/group-by.mjs +0 -1
- package/dist/array/last.mjs +0 -1
- package/dist/array/move.mjs +0 -4
- package/dist/array/select.mjs +0 -1
- package/dist/array/sort.mjs +6 -15
- package/dist/array/swap.mjs +0 -1
- package/dist/array/to-map.mjs +0 -1
- package/dist/array/to-record.mjs +0 -1
- package/dist/beacon.mjs +36 -36
- package/dist/color/instance.mjs +42 -84
- package/dist/color/misc/alpha.d.mts +3 -1
- package/dist/color/misc/alpha.mjs +8 -2
- package/dist/color/misc/is.mjs +5 -4
- package/dist/color/misc/state.d.mts +29 -4
- package/dist/color/misc/state.mjs +18 -40
- package/dist/color/space/hex.d.mts +5 -1
- package/dist/color/space/hex.mjs +21 -2
- package/dist/color/space/hsl.d.mts +6 -2
- package/dist/color/space/hsl.mjs +25 -4
- package/dist/color/space/hwb.d.mts +6 -2
- package/dist/color/space/hwb.mjs +24 -3
- package/dist/color/space/rgb.d.mts +6 -2
- package/dist/color/space/rgb.mjs +41 -20
- package/dist/function/limit.mjs +0 -2
- package/dist/function/once.mjs +30 -36
- package/dist/function/retry.mjs +0 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +488 -547
- package/dist/internal/{abort.d.mts → aborter.d.mts} +1 -1
- package/dist/internal/{abort.mjs → aborter.mjs} +1 -1
- package/dist/internal/array/get.mjs +3 -2
- package/dist/internal/array/index-of.mjs +0 -1
- package/dist/internal/function/assert.d.mts +1 -1
- package/dist/internal/function/assert.mjs +0 -7
- package/dist/internal/function/limit.mjs +10 -14
- package/dist/internal/function/memoize.mjs +22 -20
- package/dist/internal/function/work.mjs +0 -2
- package/dist/internal/herald.mjs +14 -15
- package/dist/internal/result/misc.mjs +2 -5
- package/dist/internal/subscription.mjs +24 -22
- package/dist/internal/value/compare.d.mts +1 -1
- package/dist/internal/value/compare.mjs +0 -5
- package/dist/internal/value/equal.d.mts +1 -1
- package/dist/internal/value/equal.mjs +4 -12
- package/dist/internal/value/handlers.d.mts +1 -1
- package/dist/internal/value/handlers.mjs +5 -7
- package/dist/internal/value/has.mjs +0 -1
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +4 -3
- package/dist/internal/value/partial.mjs +2 -1
- package/dist/internal/value/set.mjs +2 -1
- package/dist/logger.mjs +46 -45
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/helpers.mjs +4 -3
- package/dist/promise/index.mjs +1 -2
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/models.d.mts +1 -1
- package/dist/promise/timed.mjs +1 -1
- package/dist/queue.mjs +86 -80
- package/dist/result/index.mjs +0 -1
- package/dist/result/match.mjs +0 -1
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/string/fuzzy.mjs +18 -21
- package/dist/string/normalize.mjs +2 -3
- package/dist/string/template.mjs +2 -3
- package/dist/value/clone.d.mts +1 -1
- package/dist/value/clone.mjs +4 -12
- package/dist/value/freeze.mjs +0 -4
- package/dist/value/merge.mjs +5 -7
- package/dist/value/transform.mjs +1 -2
- package/package.json +2 -2
package/dist/promise/helpers.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainObject } from "../internal/is.mjs";
|
|
1
2
|
import { getNumberOrDefault } from "../internal/defaults.mjs";
|
|
2
3
|
import { error, ok } from "../internal/result/misc.mjs";
|
|
3
4
|
import { PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
@@ -8,7 +9,7 @@ function createPromiseOptions(input) {
|
|
|
8
9
|
signal: input,
|
|
9
10
|
time: 0
|
|
10
11
|
};
|
|
11
|
-
const options =
|
|
12
|
+
const options = isPlainObject(input) ? input : {};
|
|
12
13
|
return {
|
|
13
14
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
14
15
|
time: getNumberOrDefault(options.time, 0)
|
|
@@ -20,7 +21,7 @@ function createPromisesOptions(input) {
|
|
|
20
21
|
signal: input,
|
|
21
22
|
strategy: PROMISE_STRATEGY_DEFAULT
|
|
22
23
|
};
|
|
23
|
-
const options =
|
|
24
|
+
const options = isPlainObject(input) ? input : {};
|
|
24
25
|
return {
|
|
25
26
|
signal: options.signal instanceof AbortSignal ? options.signal : void 0,
|
|
26
27
|
strategy: getStrategyOrDefault(options.strategy)
|
|
@@ -59,7 +60,7 @@ function isRejected(value) {
|
|
|
59
60
|
return isType(value, PROMISE_TYPE_REJECTED);
|
|
60
61
|
}
|
|
61
62
|
function isType(value, type) {
|
|
62
|
-
return
|
|
63
|
+
return isPlainObject(value) && "status" in value && value.status === type;
|
|
63
64
|
}
|
|
64
65
|
//#endregion
|
|
65
66
|
export { createPromiseOptions, createPromisesOptions, getResultsFromPromises, getStrategyOrDefault, isFulfilled, isRejected };
|
package/dist/promise/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.mjs";
|
|
2
|
-
import { createAborter } from "../internal/
|
|
2
|
+
import { createAborter } from "../internal/aborter.mjs";
|
|
3
3
|
import { PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
4
4
|
import { createPromiseOptions, createPromisesOptions, getResultsFromPromises } from "./helpers.mjs";
|
|
5
5
|
import { handleResult, settlePromise } from "./misc.mjs";
|
|
@@ -75,6 +75,5 @@ async function resultPromises(items, signal) {
|
|
|
75
75
|
return promises(items, signal).then(getResultsFromPromises);
|
|
76
76
|
}
|
|
77
77
|
promises.result = resultPromises;
|
|
78
|
-
Object.defineProperty(promises, "result", { value: resultPromises });
|
|
79
78
|
//#endregion
|
|
80
79
|
export { attemptPromise, promises, resultPromises };
|
package/dist/promise/misc.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from "../internal/result/models.mjs";
|
|
2
|
-
import { Aborter } from "../internal/
|
|
2
|
+
import { Aborter } from "../internal/aborter.mjs";
|
|
3
3
|
import { CancelablePromise, PromiseParameters } from "./models.mjs";
|
|
4
4
|
import { toPromise } from "../result/misc.mjs";
|
|
5
5
|
import { isFulfilled, isRejected } from "./helpers.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrayOrPlainObject, GenericCallback, Key } from "../models.mjs";
|
|
2
2
|
import { Result } from "../internal/result/models.mjs";
|
|
3
|
-
import { Aborter } from "../internal/
|
|
3
|
+
import { Aborter } from "../internal/aborter.mjs";
|
|
4
4
|
import { PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
5
5
|
//#region src/promise/models.d.ts
|
|
6
6
|
/**
|
package/dist/promise/timed.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAborter } from "../internal/
|
|
1
|
+
import { createAborter } from "../internal/aborter.mjs";
|
|
2
2
|
import { LIMITER_WAIT, getLimiter } from "../internal/function/limit.mjs";
|
|
3
3
|
import { PROMISE_MESSAGE_EXPECTATION_TIMED } from "./constants.mjs";
|
|
4
4
|
import { PromiseTimeoutError } from "./models.mjs";
|
package/dist/queue.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAborter } from "./internal/
|
|
1
|
+
import { createAborter } from "./internal/aborter.mjs";
|
|
2
2
|
import { getBooleanOrDefault, getNumberOrDefault } from "./internal/defaults.mjs";
|
|
3
3
|
//#region src/queue.ts
|
|
4
4
|
const QUEUE_NAME_KEYED = "keyedQueue";
|
|
@@ -14,83 +14,63 @@ var QueueError = class extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
function KeyedQueue(callback, options) {
|
|
17
|
-
|
|
17
|
+
this[QUEUE_SYMBOL] = {
|
|
18
18
|
callback,
|
|
19
19
|
options: createQueueOptions(options),
|
|
20
20
|
queues: /* @__PURE__ */ new Map()
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
}
|
|
23
|
+
KeyedQueue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_KEYED;
|
|
24
|
+
KeyedQueue.prototype.add = addKeyedQueue;
|
|
25
|
+
KeyedQueue.prototype.clear = clearQueues;
|
|
26
|
+
KeyedQueue.prototype.get = getQueue;
|
|
27
|
+
KeyedQueue.prototype.pause = pauseQueues;
|
|
28
|
+
KeyedQueue.prototype.remove = removeQueue;
|
|
29
|
+
KeyedQueue.prototype.resume = resumeQueues;
|
|
23
30
|
Object.defineProperties(KeyedQueue.prototype, {
|
|
24
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_KEYED },
|
|
25
31
|
active: {
|
|
26
32
|
enumerable: true,
|
|
27
|
-
get
|
|
28
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_ACTIVE);
|
|
29
|
-
}
|
|
33
|
+
get: getActiveQueues
|
|
30
34
|
},
|
|
31
|
-
add: { value: addKeyedQueue },
|
|
32
35
|
autostart: {
|
|
33
36
|
enumerable: true,
|
|
34
|
-
get
|
|
35
|
-
return this[QUEUE_SYMBOL].options.autostart;
|
|
36
|
-
}
|
|
37
|
+
get: getQueueAutostart
|
|
37
38
|
},
|
|
38
|
-
clear: { value: clearQueues },
|
|
39
39
|
concurrency: {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get
|
|
42
|
-
return this[QUEUE_SYMBOL].options.concurrency;
|
|
43
|
-
}
|
|
41
|
+
get: getQueueConcurrency
|
|
44
42
|
},
|
|
45
43
|
empty: {
|
|
46
44
|
enumerable: true,
|
|
47
|
-
get
|
|
48
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_EMPTY);
|
|
49
|
-
}
|
|
45
|
+
get: getEmptyQueues
|
|
50
46
|
},
|
|
51
47
|
full: {
|
|
52
48
|
enumerable: true,
|
|
53
|
-
get
|
|
54
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_FULL);
|
|
55
|
-
}
|
|
49
|
+
get: getFullQueues
|
|
56
50
|
},
|
|
57
|
-
get: { value: getQueue },
|
|
58
51
|
items: {
|
|
59
52
|
enumerable: true,
|
|
60
|
-
get
|
|
61
|
-
return getQueueItems(this[QUEUE_SYMBOL]);
|
|
62
|
-
}
|
|
53
|
+
get: getKeyedQueueItems
|
|
63
54
|
},
|
|
64
55
|
keys: {
|
|
65
56
|
enumerable: true,
|
|
66
|
-
get
|
|
67
|
-
return [...this[QUEUE_SYMBOL].queues.keys()];
|
|
68
|
-
}
|
|
57
|
+
get: getQueueKeys
|
|
69
58
|
},
|
|
70
59
|
maximum: {
|
|
71
60
|
enumerable: true,
|
|
72
|
-
get
|
|
73
|
-
return this[QUEUE_SYMBOL].options.maximum;
|
|
74
|
-
}
|
|
61
|
+
get: getQueueMaximum
|
|
75
62
|
},
|
|
76
|
-
pause: { value: pauseQueues },
|
|
77
63
|
paused: {
|
|
78
64
|
enumerable: true,
|
|
79
|
-
get
|
|
80
|
-
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_PAUSED);
|
|
81
|
-
}
|
|
65
|
+
get: getPausedQueues
|
|
82
66
|
},
|
|
83
67
|
queues: {
|
|
84
68
|
enumerable: true,
|
|
85
|
-
get
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
remove: { value: removeQueue },
|
|
90
|
-
resume: { value: resumeQueues }
|
|
69
|
+
get: getKeyedQueueSize
|
|
70
|
+
}
|
|
91
71
|
});
|
|
92
72
|
function Queue(callback, options, key) {
|
|
93
|
-
|
|
73
|
+
this[QUEUE_SYMBOL] = {
|
|
94
74
|
callback,
|
|
95
75
|
key,
|
|
96
76
|
options,
|
|
@@ -99,63 +79,46 @@ function Queue(callback, options, key) {
|
|
|
99
79
|
items: [],
|
|
100
80
|
paused: !options.autostart,
|
|
101
81
|
runners: 0
|
|
102
|
-
}
|
|
82
|
+
};
|
|
103
83
|
}
|
|
84
|
+
Queue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_QUEUE;
|
|
85
|
+
Queue.prototype.add = addToQueue;
|
|
86
|
+
Queue.prototype.clear = clearQueue;
|
|
87
|
+
Queue.prototype.pause = pauseQueue;
|
|
88
|
+
Queue.prototype.remove = removeQueued;
|
|
89
|
+
Queue.prototype.resume = resumeQueue;
|
|
104
90
|
Object.defineProperties(Queue.prototype, {
|
|
105
|
-
[QUEUE_PROPERTY]: { value: QUEUE_NAME_QUEUE },
|
|
106
91
|
active: {
|
|
107
92
|
enumerable: true,
|
|
108
|
-
get
|
|
109
|
-
return this[QUEUE_SYMBOL].runners > 0;
|
|
110
|
-
}
|
|
93
|
+
get: getQueueActive
|
|
111
94
|
},
|
|
112
|
-
add: { value: addToQueue },
|
|
113
95
|
autostart: {
|
|
114
96
|
enumerable: true,
|
|
115
|
-
get
|
|
116
|
-
return this[QUEUE_SYMBOL].options.autostart;
|
|
117
|
-
}
|
|
97
|
+
get: getQueueAutostart
|
|
118
98
|
},
|
|
119
|
-
clear: { value: clearQueue },
|
|
120
99
|
concurrency: {
|
|
121
100
|
enumerable: true,
|
|
122
|
-
get
|
|
123
|
-
return this[QUEUE_SYMBOL].options.concurrency;
|
|
124
|
-
}
|
|
101
|
+
get: getQueueConcurrency
|
|
125
102
|
},
|
|
126
103
|
empty: {
|
|
127
104
|
enumerable: true,
|
|
128
|
-
get
|
|
129
|
-
return this[QUEUE_SYMBOL].items.length === 0;
|
|
130
|
-
}
|
|
105
|
+
get: getQueueEmpty
|
|
131
106
|
},
|
|
132
107
|
full: {
|
|
133
108
|
enumerable: true,
|
|
134
|
-
get
|
|
135
|
-
const state = this[QUEUE_SYMBOL];
|
|
136
|
-
return state.options.maximum > 0 && state.items.length >= state.options.maximum;
|
|
137
|
-
}
|
|
109
|
+
get: getQueueFull
|
|
138
110
|
},
|
|
139
111
|
maximum: {
|
|
140
112
|
enumerable: true,
|
|
141
|
-
get
|
|
142
|
-
return this[QUEUE_SYMBOL].options.maximum;
|
|
143
|
-
}
|
|
113
|
+
get: getQueueMaximum
|
|
144
114
|
},
|
|
145
|
-
pause: { value: pauseQueue },
|
|
146
115
|
paused: {
|
|
147
116
|
enumerable: true,
|
|
148
|
-
get
|
|
149
|
-
return this[QUEUE_SYMBOL].paused;
|
|
150
|
-
}
|
|
117
|
+
get: getQueuePaused
|
|
151
118
|
},
|
|
152
|
-
remove: { value: removeQueued },
|
|
153
|
-
resume: { value: resumeQueue },
|
|
154
119
|
size: {
|
|
155
120
|
enumerable: true,
|
|
156
|
-
get
|
|
157
|
-
return this[QUEUE_SYMBOL].items.length;
|
|
158
|
-
}
|
|
121
|
+
get: getQueueSize
|
|
159
122
|
}
|
|
160
123
|
});
|
|
161
124
|
function addKeyedQueue(key, parameters, signal) {
|
|
@@ -213,6 +176,28 @@ function createQueueOptions(input) {
|
|
|
213
176
|
maximum: getNumberOrDefault(options.maximum, 0)
|
|
214
177
|
};
|
|
215
178
|
}
|
|
179
|
+
function getActiveQueues() {
|
|
180
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_ACTIVE);
|
|
181
|
+
}
|
|
182
|
+
function getEmptyQueues() {
|
|
183
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_EMPTY);
|
|
184
|
+
}
|
|
185
|
+
function getFullQueues() {
|
|
186
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_FULL);
|
|
187
|
+
}
|
|
188
|
+
function getPausedQueues() {
|
|
189
|
+
return getStatus(this[QUEUE_SYMBOL], QUEUE_STATUS_PAUSED);
|
|
190
|
+
}
|
|
191
|
+
function getKeyedQueueItems() {
|
|
192
|
+
const state = this[QUEUE_SYMBOL];
|
|
193
|
+
const size = {};
|
|
194
|
+
const queues = state.queues.entries();
|
|
195
|
+
for (const [key, queue] of queues) size[key] = queue.size;
|
|
196
|
+
return size;
|
|
197
|
+
}
|
|
198
|
+
function getKeyedQueueSize() {
|
|
199
|
+
return this[QUEUE_SYMBOL].queues.size;
|
|
200
|
+
}
|
|
216
201
|
function getQueue(key, add) {
|
|
217
202
|
if (typeof key !== "string" || key.trim().length === 0) throw new TypeError(QUEUE_MESSAGE_KEY);
|
|
218
203
|
const state = this[QUEUE_SYMBOL];
|
|
@@ -223,11 +208,33 @@ function getQueue(key, add) {
|
|
|
223
208
|
}
|
|
224
209
|
return queue;
|
|
225
210
|
}
|
|
226
|
-
function
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return
|
|
211
|
+
function getQueueActive() {
|
|
212
|
+
return this[QUEUE_SYMBOL].runners > 0;
|
|
213
|
+
}
|
|
214
|
+
function getQueueAutostart() {
|
|
215
|
+
return this[QUEUE_SYMBOL].options.autostart === true;
|
|
216
|
+
}
|
|
217
|
+
function getQueueConcurrency() {
|
|
218
|
+
return this[QUEUE_SYMBOL].options.concurrency;
|
|
219
|
+
}
|
|
220
|
+
function getQueueEmpty() {
|
|
221
|
+
return this[QUEUE_SYMBOL].items.length === 0;
|
|
222
|
+
}
|
|
223
|
+
function getQueueFull() {
|
|
224
|
+
const state = this[QUEUE_SYMBOL];
|
|
225
|
+
return state.options.maximum > 0 && state.items.length >= state.options.maximum;
|
|
226
|
+
}
|
|
227
|
+
function getQueueKeys() {
|
|
228
|
+
return [...this[QUEUE_SYMBOL].queues.keys()];
|
|
229
|
+
}
|
|
230
|
+
function getQueueMaximum() {
|
|
231
|
+
return this[QUEUE_SYMBOL].options.maximum;
|
|
232
|
+
}
|
|
233
|
+
function getQueuePaused() {
|
|
234
|
+
return this[QUEUE_SYMBOL].paused === true;
|
|
235
|
+
}
|
|
236
|
+
function getQueueSize() {
|
|
237
|
+
return this[QUEUE_SYMBOL].items.length;
|
|
231
238
|
}
|
|
232
239
|
function getStatus(state, status) {
|
|
233
240
|
const queues = state.queues.entries();
|
|
@@ -373,6 +380,5 @@ const QUEUE_STATUS_FULL = "full";
|
|
|
373
380
|
const QUEUE_STATUS_PAUSED = "paused";
|
|
374
381
|
const QUEUE_SYMBOL = Symbol(QUEUE_PROPERTY);
|
|
375
382
|
queue.keyed = keyedQueue;
|
|
376
|
-
Object.defineProperty(queue, "keyed", { value: keyedQueue });
|
|
377
383
|
//#endregion
|
|
378
384
|
export { QueueError, isKeyedQueue, isQueue, isQueueInstance, keyedQueue, queue };
|
package/dist/result/index.mjs
CHANGED
package/dist/result/match.mjs
CHANGED
|
@@ -23,6 +23,5 @@ function matchResult(result, first, error) {
|
|
|
23
23
|
}
|
|
24
24
|
const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
|
|
25
25
|
matchResult.async = asyncMatchResult;
|
|
26
|
-
Object.defineProperty(matchResult, "async", { value: asyncMatchResult });
|
|
27
26
|
//#endregion
|
|
28
27
|
export { asyncMatchResult, matchResult };
|
package/dist/string/fuzzy.mjs
CHANGED
|
@@ -6,27 +6,24 @@ import { includes } from "./match.mjs";
|
|
|
6
6
|
const FUZZY_PROPERTY = "$fuzzy";
|
|
7
7
|
const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
|
|
8
8
|
function Fuzzy(state) {
|
|
9
|
-
|
|
9
|
+
this[FUZZY_SYMBOL] = state;
|
|
10
10
|
}
|
|
11
|
+
Fuzzy.prototype[FUZZY_PROPERTY] = true;
|
|
12
|
+
Fuzzy.prototype.search = search;
|
|
11
13
|
Object.defineProperties(Fuzzy.prototype, {
|
|
12
|
-
[FUZZY_PROPERTY]: { value: true },
|
|
13
14
|
items: {
|
|
14
15
|
enumerable: true,
|
|
15
|
-
get
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
set(value) {
|
|
19
|
-
setItems(this[FUZZY_SYMBOL], value);
|
|
20
|
-
}
|
|
16
|
+
get: getFuzzyItems,
|
|
17
|
+
set: setFuzzyItems
|
|
21
18
|
},
|
|
22
|
-
search: { value: search },
|
|
23
19
|
strings: {
|
|
24
20
|
enumerable: true,
|
|
25
|
-
get
|
|
26
|
-
return this[FUZZY_SYMBOL].strings.slice();
|
|
27
|
-
}
|
|
21
|
+
get: getFuzzyStrings
|
|
28
22
|
}
|
|
29
23
|
});
|
|
24
|
+
function createFuzzyItems(items) {
|
|
25
|
+
return items.sort((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
|
|
26
|
+
}
|
|
30
27
|
function createFuzzyOptions(input, state) {
|
|
31
28
|
const options = isPlainObject(input) ? input : {};
|
|
32
29
|
const limit = typeof input === "number" ? input : options.limit;
|
|
@@ -75,8 +72,11 @@ function getHandler(input) {
|
|
|
75
72
|
throw new TypeError(FUZZY_MESSAGE_HANDLER);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
function getFuzzyItems(
|
|
79
|
-
return items.
|
|
75
|
+
function getFuzzyItems() {
|
|
76
|
+
return this[FUZZY_SYMBOL].items.slice();
|
|
77
|
+
}
|
|
78
|
+
function getFuzzyStrings() {
|
|
79
|
+
return this[FUZZY_SYMBOL].strings.slice();
|
|
80
80
|
}
|
|
81
81
|
function getScore(haystack, needle) {
|
|
82
82
|
if (!isSubsequence(haystack, needle)) return -1;
|
|
@@ -171,16 +171,17 @@ function search(input, option) {
|
|
|
171
171
|
for (let index = 0; index < length; index += 1) {
|
|
172
172
|
const key = keys[index];
|
|
173
173
|
if (maxScore - key > options.tolerance) break;
|
|
174
|
-
similar.push(...
|
|
174
|
+
similar.push(...createFuzzyItems(scored[key]));
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
result.exact =
|
|
177
|
+
result.exact = createFuzzyItems(options.limit == null ? exact : exact.slice(0, options.limit));
|
|
178
178
|
if (options.limit == null) result.similar = similar;
|
|
179
179
|
else result.similar = similar.slice(0, options.limit - result.exact.length);
|
|
180
180
|
return result;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function setFuzzyItems(value) {
|
|
183
183
|
if (!Array.isArray(value)) throw new TypeError(FUZZY_MESSAGE_ARRAY);
|
|
184
|
+
const state = this[FUZZY_SYMBOL];
|
|
184
185
|
state.items = value.slice();
|
|
185
186
|
state.strings = value.map(state.handler);
|
|
186
187
|
}
|
|
@@ -190,9 +191,5 @@ const FUZZY_MESSAGE_HANDLER = "Fuzzy requires a key or function to stringify ite
|
|
|
190
191
|
const FUZZY_PROXIMITY_THRESHOLD = 5;
|
|
191
192
|
fuzzy.is = isFuzzy;
|
|
192
193
|
fuzzy.match = fuzzyMatch;
|
|
193
|
-
Object.defineProperties(fuzzy, {
|
|
194
|
-
is: { value: isFuzzy },
|
|
195
|
-
match: { value: fuzzyMatch }
|
|
196
|
-
});
|
|
197
194
|
//#endregion
|
|
198
195
|
export { fuzzy, fuzzyMatch, isFuzzy };
|
|
@@ -3,9 +3,9 @@ import { memoize } from "../internal/function/memoize.mjs";
|
|
|
3
3
|
import { lowerCase } from "../internal/string/case.mjs";
|
|
4
4
|
//#region src/string/normalize.ts
|
|
5
5
|
function Normalizer(options) {
|
|
6
|
-
|
|
6
|
+
this[NORMALIZE_SYMBOL] = options;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
Normalizer.prototype.normalize = normalizeString;
|
|
9
9
|
function createNormalizeOptions(input) {
|
|
10
10
|
const options = isPlainObject(input) ? input : {};
|
|
11
11
|
return {
|
|
@@ -108,6 +108,5 @@ const NORMALIZE_WHITESPACE_PATTERN = /\s+/g;
|
|
|
108
108
|
const NORMALIZE_WHITESPACE_REPLACEMENT = " ";
|
|
109
109
|
let deburrMemoizer;
|
|
110
110
|
normalize.initialize = initializeNormalizer;
|
|
111
|
-
Object.defineProperty(normalize, "initialize", { value: initializeNormalizer });
|
|
112
111
|
//#endregion
|
|
113
112
|
export { deburr, initializeNormalizer, normalize };
|
package/dist/string/template.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { getString, interpolate } from "../internal/string/misc.mjs";
|
|
|
3
3
|
import { getValue } from "../internal/value/get.mjs";
|
|
4
4
|
//#region src/string/template.ts
|
|
5
5
|
function Templater(options) {
|
|
6
|
-
|
|
6
|
+
this[TEMPLATE_SYMBOL] = options;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
Templater.prototype.render = render;
|
|
9
9
|
function createTemplateOptions(input) {
|
|
10
10
|
const options = isPlainObject(input) ? input : {};
|
|
11
11
|
return {
|
|
@@ -54,6 +54,5 @@ function template(value, ...parameters) {
|
|
|
54
54
|
const TEMPLATE_EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
|
|
55
55
|
const TEMPLATE_SYMBOL = Symbol("template");
|
|
56
56
|
template.initialize = initializeTemplater;
|
|
57
|
-
Object.defineProperty(template, "initialize", { value: initializeTemplater });
|
|
58
57
|
//#endregion
|
|
59
58
|
export { initializeTemplater, template };
|
package/dist/value/clone.d.mts
CHANGED
|
@@ -51,7 +51,7 @@ export declare namespace clone {
|
|
|
51
51
|
var deregister: typeof deregisterCloner;
|
|
52
52
|
var handlers: {
|
|
53
53
|
base: {
|
|
54
|
-
handlers: WeakMap<
|
|
54
|
+
handlers: WeakMap<WeakKey, string | GenericCallback>;
|
|
55
55
|
options: {
|
|
56
56
|
callback: GenericCallback;
|
|
57
57
|
method?: string;
|
package/dist/value/clone.mjs
CHANGED
|
@@ -3,13 +3,11 @@ import { createValueHandler } from "../internal/value/handlers.mjs";
|
|
|
3
3
|
//#region src/value/clone.ts
|
|
4
4
|
const CLONE_NAME = "clone";
|
|
5
5
|
function Cloner(options) {
|
|
6
|
-
|
|
6
|
+
this[CLONE_SYMBOL] = options;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
register: { value: registerCloner }
|
|
12
|
-
});
|
|
8
|
+
Cloner.prototype.clone = cloneFromCloner;
|
|
9
|
+
Cloner.prototype.deregister = deregisterCloner;
|
|
10
|
+
Cloner.prototype.register = registerCloner;
|
|
13
11
|
function clone(value, options) {
|
|
14
12
|
return cloneAny(value, { copy: false }, 0, options);
|
|
15
13
|
}
|
|
@@ -193,11 +191,5 @@ clone.deregister = deregisterCloner;
|
|
|
193
191
|
clone.handlers = cloneHandler;
|
|
194
192
|
clone.initialize = initializeCloner;
|
|
195
193
|
clone.register = registerCloner;
|
|
196
|
-
Object.defineProperties(clone, {
|
|
197
|
-
deregister: { value: deregisterCloner },
|
|
198
|
-
handler: { value: cloneHandler },
|
|
199
|
-
initialize: { value: initializeCloner },
|
|
200
|
-
register: { value: registerCloner }
|
|
201
|
-
});
|
|
202
194
|
//#endregion
|
|
203
195
|
export { clone, copy, deregisterCloner, initializeCloner, registerCloner };
|
package/dist/value/freeze.mjs
CHANGED
|
@@ -78,9 +78,5 @@ function isFrozen(value) {
|
|
|
78
78
|
const frozenValues = /* @__PURE__ */ new WeakSet();
|
|
79
79
|
freeze.flat = flatFreeze;
|
|
80
80
|
freeze.is = isFrozen;
|
|
81
|
-
Object.defineProperties(freeze, {
|
|
82
|
-
flat: { value: flatFreeze },
|
|
83
|
-
is: { value: isFrozen }
|
|
84
|
-
});
|
|
85
81
|
//#endregion
|
|
86
82
|
export { flatFreeze, freeze, isFrozen };
|
package/dist/value/merge.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isArrayOrPlainObject } from "../internal/is.mjs";
|
|
2
2
|
//#region src/value/merge.ts
|
|
3
3
|
function Assigner(options) {
|
|
4
|
-
|
|
4
|
+
this[MERGE_SYMBOL_ASSIGN] = {
|
|
5
5
|
...options,
|
|
6
6
|
assignValues: true
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
Assigner.prototype.assign = assignFromAssigner;
|
|
10
10
|
function Merger(options) {
|
|
11
|
-
|
|
11
|
+
this[MERGE_SYMBOL_MERGE] = options;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
Merger.prototype.merge = mergeFromMerger;
|
|
14
14
|
/**
|
|
15
15
|
* Assign values from one or more objects to the first one
|
|
16
16
|
*
|
|
@@ -114,7 +114,5 @@ const MERGE_SYMBOL_ASSIGN = Symbol("assign");
|
|
|
114
114
|
const MERGE_SYMBOL_MERGE = Symbol("merge");
|
|
115
115
|
assign.initialize = initializeAssigner;
|
|
116
116
|
merge.initialize = initializeMerger;
|
|
117
|
-
Object.defineProperty(assign, "initialize", { value: initializeAssigner });
|
|
118
|
-
Object.defineProperty(merge, "initialize", { value: initializeMerger });
|
|
119
117
|
//#endregion
|
|
120
118
|
export { assign, initializeAssigner, initializeMerger, merge };
|
package/dist/value/transform.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNonPlainObject } from "../internal/is.mjs";
|
|
2
2
|
//#region src/value/transform.ts
|
|
3
3
|
function Transformer(transformer) {
|
|
4
|
-
|
|
4
|
+
this[TRANSFORM_SYMBOL] = transformer;
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperties(Transformer.prototype, { transform: { value: transformValue } });
|
|
7
7
|
function getTransformHandler(input) {
|
|
@@ -39,6 +39,5 @@ function transformValue(value) {
|
|
|
39
39
|
}
|
|
40
40
|
const TRANSFORM_SYMBOL = Symbol("transform");
|
|
41
41
|
transform.initialize = initializeTransformer;
|
|
42
|
-
Object.defineProperty(transform, "initialize", { value: initializeTransformer });
|
|
43
42
|
//#endregion
|
|
44
43
|
export { initializeTransformer, transform };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscarpalmer/atoms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.204.0",
|
|
4
4
|
"description": "Atomic utilities for making your JavaScript better.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
"watch": "npx vite build --watch"
|
|
279
279
|
},
|
|
280
280
|
"devDependencies": {
|
|
281
|
-
"@oxlint/plugins": "^1.
|
|
281
|
+
"@oxlint/plugins": "^1.83",
|
|
282
282
|
"@types/node": "^26.5",
|
|
283
283
|
"@vitest/coverage-istanbul": "^4.1",
|
|
284
284
|
"eslint": "^10.10",
|