@baleada/logic 0.20.34 → 0.21.2
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/lib/index.cjs +52 -338
- package/lib/index.d.ts +156 -316
- package/lib/index.js +54 -339
- package/package.json +5 -6
package/lib/index.cjs
CHANGED
|
@@ -50,34 +50,30 @@ function createFilterAsync(condition) {
|
|
|
50
50
|
return createFilter((_, index) => transformedAsync[index])(array);
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function createDelete(
|
|
53
|
+
function createDelete(index) {
|
|
54
54
|
return (array) => {
|
|
55
|
-
|
|
56
|
-
return createConcat(createSlice({ from: 0, to: deleteIndex })(array), createSlice({ from: deleteIndex + 1 })(array))([]);
|
|
55
|
+
return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
|
-
function createInsert(
|
|
58
|
+
function createInsert(item, index) {
|
|
60
59
|
return (array) => {
|
|
61
|
-
const
|
|
62
|
-
return createReorder({
|
|
63
|
-
from: { start: array.length, itemCount: itemsToInsert.length },
|
|
64
|
-
to: required.index
|
|
65
|
-
})(withItems);
|
|
60
|
+
const withItems = createConcat(array, [item])([]);
|
|
61
|
+
return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
|
|
66
62
|
};
|
|
67
63
|
}
|
|
68
|
-
function createReorder(
|
|
64
|
+
function createReorder(from, to) {
|
|
69
65
|
return (array) => {
|
|
70
66
|
const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
|
|
71
67
|
if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
|
|
72
68
|
return array;
|
|
73
69
|
}
|
|
74
|
-
const itemsToMove = createSlice(
|
|
70
|
+
const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
75
71
|
if (itemsToMoveStartIndex < insertIndex) {
|
|
76
|
-
const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(
|
|
72
|
+
const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
|
|
77
73
|
return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
|
|
78
74
|
}
|
|
79
75
|
if (itemsToMoveStartIndex > insertIndex) {
|
|
80
|
-
const beforeInsertion = insertIndex === 0 ? [] : createSlice(
|
|
76
|
+
const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
81
77
|
return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
|
|
82
78
|
}
|
|
83
79
|
return array;
|
|
@@ -86,19 +82,19 @@ function createReorder({ from, to }) {
|
|
|
86
82
|
function isObject(value) {
|
|
87
83
|
return typeof value === "object";
|
|
88
84
|
}
|
|
89
|
-
function createSwap(
|
|
85
|
+
function createSwap(indices) {
|
|
90
86
|
return (array) => {
|
|
91
87
|
const { 0: from, 1: to } = indices, { reorderFrom, reorderTo } = (() => {
|
|
92
88
|
if (from < to) {
|
|
93
89
|
return {
|
|
94
|
-
reorderFrom: createReorder(
|
|
95
|
-
reorderTo: createReorder(
|
|
90
|
+
reorderFrom: createReorder(from, to),
|
|
91
|
+
reorderTo: createReorder(to - 1, from)
|
|
96
92
|
};
|
|
97
93
|
}
|
|
98
94
|
if (from > to) {
|
|
99
95
|
return {
|
|
100
|
-
reorderFrom: createReorder(
|
|
101
|
-
reorderTo: createReorder(
|
|
96
|
+
reorderFrom: createReorder(from, to),
|
|
97
|
+
reorderTo: createReorder(to + 1, from)
|
|
102
98
|
};
|
|
103
99
|
}
|
|
104
100
|
return {
|
|
@@ -109,15 +105,15 @@ function createSwap({ indices }) {
|
|
|
109
105
|
return new Pipeable(array).pipe(reorderFrom, reorderTo);
|
|
110
106
|
};
|
|
111
107
|
}
|
|
112
|
-
function createReplace(
|
|
108
|
+
function createReplace(index, item) {
|
|
113
109
|
return (array) => {
|
|
114
|
-
return createConcat(createSlice(
|
|
110
|
+
return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
|
|
115
111
|
};
|
|
116
112
|
}
|
|
117
113
|
function createUnique() {
|
|
118
114
|
return (array) => lazyCollections.pipe(lazyCollections.unique(), lazyCollections.toArray())(array);
|
|
119
115
|
}
|
|
120
|
-
function createSlice(
|
|
116
|
+
function createSlice(from, to) {
|
|
121
117
|
return (array) => {
|
|
122
118
|
return from === to ? [] : lazyCollections.pipe(lazyCollections.slice(from, to - 1), lazyCollections.toArray())(array);
|
|
123
119
|
};
|
|
@@ -142,7 +138,7 @@ function createReverse() {
|
|
|
142
138
|
}
|
|
143
139
|
function createSort(compare) {
|
|
144
140
|
return (array) => {
|
|
145
|
-
return new Pipeable(array).pipe(createSlice(
|
|
141
|
+
return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
|
|
146
142
|
};
|
|
147
143
|
}
|
|
148
144
|
function createSlug(options) {
|
|
@@ -155,7 +151,7 @@ function createClip(required) {
|
|
|
155
151
|
return string.replace(required, "");
|
|
156
152
|
};
|
|
157
153
|
}
|
|
158
|
-
function createClamp(
|
|
154
|
+
function createClamp(min, max) {
|
|
159
155
|
return (number) => {
|
|
160
156
|
const maxed = Math.max(number, min);
|
|
161
157
|
return Math.min(maxed, max);
|
|
@@ -171,9 +167,9 @@ function createDetermine(potentialities) {
|
|
|
171
167
|
})(potentialities);
|
|
172
168
|
return (determinant) => lazyCollections.find(({ predicate }) => predicate(determinant))(predicates).outcome;
|
|
173
169
|
}
|
|
174
|
-
function createRename(
|
|
170
|
+
function createRename(from, to) {
|
|
175
171
|
return (map2) => {
|
|
176
|
-
const keys = [...map2.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace(
|
|
172
|
+
const keys = [...map2.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace(keyToRenameIndex, to)(keys), values = [...map2.values()];
|
|
177
173
|
return createReduce((renamed, key, index) => renamed.set(key, values[index]), /* @__PURE__ */ new Map())(newKeys);
|
|
178
174
|
};
|
|
179
175
|
}
|
|
@@ -198,239 +194,6 @@ class Pipeable {
|
|
|
198
194
|
}
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
function toEvent(eventType, options) {
|
|
202
|
-
const implementation = toImplementation(eventType);
|
|
203
|
-
switch (implementation) {
|
|
204
|
-
case "keycombo": {
|
|
205
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
206
|
-
return new KeyboardEvent("keyDirection" in options ? `key${options.keyDirection}` : "keydown", {
|
|
207
|
-
...options.init || {},
|
|
208
|
-
key: toKey(name),
|
|
209
|
-
...createReduce((flags, alias) => {
|
|
210
|
-
flags[toModifierFlag(alias)] = true;
|
|
211
|
-
return flags;
|
|
212
|
-
}, {})(modifiers)
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
case "leftclickcombo":
|
|
216
|
-
case "rightclickcombo": {
|
|
217
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
218
|
-
return new MouseEvent(name === "rightclick" ? "contextmenu" : name, {
|
|
219
|
-
...options.init || {},
|
|
220
|
-
...createReduce((flags, alias) => {
|
|
221
|
-
flags[toModifierFlag(alias)] = true;
|
|
222
|
-
return flags;
|
|
223
|
-
}, {})(modifiers)
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
case "pointercombo": {
|
|
227
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
228
|
-
return new PointerEvent(name === "rightclick" ? "contextmenu" : name, {
|
|
229
|
-
...options.init || {},
|
|
230
|
-
...createReduce((flags, alias) => {
|
|
231
|
-
flags[toModifierFlag(alias)] = true;
|
|
232
|
-
return flags;
|
|
233
|
-
}, {})(modifiers)
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
case "documentevent":
|
|
237
|
-
case "event":
|
|
238
|
-
if (eventType === "abort")
|
|
239
|
-
return new UIEvent(eventType, options.init);
|
|
240
|
-
if (eventType === "animationcancel")
|
|
241
|
-
return new AnimationEvent(eventType, options.init);
|
|
242
|
-
if (eventType === "animationend")
|
|
243
|
-
return new AnimationEvent(eventType, options.init);
|
|
244
|
-
if (eventType === "animationiteration")
|
|
245
|
-
return new AnimationEvent(eventType, options.init);
|
|
246
|
-
if (eventType === "animationstart")
|
|
247
|
-
return new AnimationEvent(eventType, options.init);
|
|
248
|
-
if (eventType === "auxclick")
|
|
249
|
-
return new MouseEvent(eventType, options.init);
|
|
250
|
-
if (eventType === "beforeinput")
|
|
251
|
-
return new InputEvent(eventType, options.init);
|
|
252
|
-
if (eventType === "blur")
|
|
253
|
-
return new FocusEvent(eventType, options.init);
|
|
254
|
-
if (eventType === "canplay")
|
|
255
|
-
return new Event(eventType, options.init);
|
|
256
|
-
if (eventType === "canplaythrough")
|
|
257
|
-
return new Event(eventType, options.init);
|
|
258
|
-
if (eventType === "change")
|
|
259
|
-
return new Event(eventType, options.init);
|
|
260
|
-
if (eventType === "click")
|
|
261
|
-
return new MouseEvent(eventType, options.init);
|
|
262
|
-
if (eventType === "close")
|
|
263
|
-
return new Event(eventType, options.init);
|
|
264
|
-
if (eventType === "compositionend")
|
|
265
|
-
return new CompositionEvent(eventType, options.init);
|
|
266
|
-
if (eventType === "compositionstart")
|
|
267
|
-
return new CompositionEvent(eventType, options.init);
|
|
268
|
-
if (eventType === "compositionupdate")
|
|
269
|
-
return new CompositionEvent(eventType, options.init);
|
|
270
|
-
if (eventType === "contextmenu")
|
|
271
|
-
return new MouseEvent(eventType, options.init);
|
|
272
|
-
if (eventType === "cuechange")
|
|
273
|
-
return new Event(eventType, options.init);
|
|
274
|
-
if (eventType === "dblclick")
|
|
275
|
-
return new MouseEvent(eventType, options.init);
|
|
276
|
-
if (eventType === "drag")
|
|
277
|
-
return new DragEvent(eventType, options.init);
|
|
278
|
-
if (eventType === "dragend")
|
|
279
|
-
return new DragEvent(eventType, options.init);
|
|
280
|
-
if (eventType === "dragenter")
|
|
281
|
-
return new DragEvent(eventType, options.init);
|
|
282
|
-
if (eventType === "dragleave")
|
|
283
|
-
return new DragEvent(eventType, options.init);
|
|
284
|
-
if (eventType === "dragover")
|
|
285
|
-
return new DragEvent(eventType, options.init);
|
|
286
|
-
if (eventType === "dragstart")
|
|
287
|
-
return new DragEvent(eventType, options.init);
|
|
288
|
-
if (eventType === "drop")
|
|
289
|
-
return new DragEvent(eventType, options.init);
|
|
290
|
-
if (eventType === "durationchange")
|
|
291
|
-
return new Event(eventType, options.init);
|
|
292
|
-
if (eventType === "emptied")
|
|
293
|
-
return new Event(eventType, options.init);
|
|
294
|
-
if (eventType === "ended")
|
|
295
|
-
return new Event(eventType, options.init);
|
|
296
|
-
if (eventType === "error")
|
|
297
|
-
return new ErrorEvent(eventType, options.init);
|
|
298
|
-
if (eventType === "focus")
|
|
299
|
-
return new FocusEvent(eventType, options.init);
|
|
300
|
-
if (eventType === "focusin")
|
|
301
|
-
return new FocusEvent(eventType, options.init);
|
|
302
|
-
if (eventType === "focusout")
|
|
303
|
-
return new FocusEvent(eventType, options.init);
|
|
304
|
-
if (eventType === "gotpointercapture")
|
|
305
|
-
return new PointerEvent(eventType, options.init);
|
|
306
|
-
if (eventType === "input")
|
|
307
|
-
return new Event(eventType, options.init);
|
|
308
|
-
if (eventType === "invalid")
|
|
309
|
-
return new Event(eventType, options.init);
|
|
310
|
-
if (eventType === "keydown")
|
|
311
|
-
return new KeyboardEvent(eventType, options.init);
|
|
312
|
-
if (eventType === "keypress")
|
|
313
|
-
return new KeyboardEvent(eventType, options.init);
|
|
314
|
-
if (eventType === "keyup")
|
|
315
|
-
return new KeyboardEvent(eventType, options.init);
|
|
316
|
-
if (eventType === "load")
|
|
317
|
-
return new Event(eventType, options.init);
|
|
318
|
-
if (eventType === "loadeddata")
|
|
319
|
-
return new Event(eventType, options.init);
|
|
320
|
-
if (eventType === "loadedmetadata")
|
|
321
|
-
return new Event(eventType, options.init);
|
|
322
|
-
if (eventType === "loadstart")
|
|
323
|
-
return new Event(eventType, options.init);
|
|
324
|
-
if (eventType === "lostpointercapture")
|
|
325
|
-
return new PointerEvent(eventType, options.init);
|
|
326
|
-
if (eventType === "mousedown")
|
|
327
|
-
return new MouseEvent(eventType, options.init);
|
|
328
|
-
if (eventType === "mouseenter")
|
|
329
|
-
return new MouseEvent(eventType, options.init);
|
|
330
|
-
if (eventType === "mouseleave")
|
|
331
|
-
return new MouseEvent(eventType, options.init);
|
|
332
|
-
if (eventType === "mousemove")
|
|
333
|
-
return new MouseEvent(eventType, options.init);
|
|
334
|
-
if (eventType === "mouseout")
|
|
335
|
-
return new MouseEvent(eventType, options.init);
|
|
336
|
-
if (eventType === "mouseover")
|
|
337
|
-
return new MouseEvent(eventType, options.init);
|
|
338
|
-
if (eventType === "mouseup")
|
|
339
|
-
return new MouseEvent(eventType, options.init);
|
|
340
|
-
if (eventType === "pause")
|
|
341
|
-
return new Event(eventType, options.init);
|
|
342
|
-
if (eventType === "play")
|
|
343
|
-
return new Event(eventType, options.init);
|
|
344
|
-
if (eventType === "playing")
|
|
345
|
-
return new Event(eventType, options.init);
|
|
346
|
-
if (eventType === "pointercancel")
|
|
347
|
-
return new PointerEvent(eventType, options.init);
|
|
348
|
-
if (eventType === "pointerdown")
|
|
349
|
-
return new PointerEvent(eventType, options.init);
|
|
350
|
-
if (eventType === "pointerenter")
|
|
351
|
-
return new PointerEvent(eventType, options.init);
|
|
352
|
-
if (eventType === "pointerleave")
|
|
353
|
-
return new PointerEvent(eventType, options.init);
|
|
354
|
-
if (eventType === "pointermove")
|
|
355
|
-
return new PointerEvent(eventType, options.init);
|
|
356
|
-
if (eventType === "pointerout")
|
|
357
|
-
return new PointerEvent(eventType, options.init);
|
|
358
|
-
if (eventType === "pointerover")
|
|
359
|
-
return new PointerEvent(eventType, options.init);
|
|
360
|
-
if (eventType === "pointerup")
|
|
361
|
-
return new PointerEvent(eventType, options.init);
|
|
362
|
-
if (eventType === "progress")
|
|
363
|
-
return new ProgressEvent(eventType, options.init);
|
|
364
|
-
if (eventType === "ratechange")
|
|
365
|
-
return new Event(eventType, options.init);
|
|
366
|
-
if (eventType === "reset")
|
|
367
|
-
return new Event(eventType, options.init);
|
|
368
|
-
if (eventType === "scroll")
|
|
369
|
-
return new Event(eventType, options.init);
|
|
370
|
-
if (eventType === "securitypolicyviolation")
|
|
371
|
-
return new SecurityPolicyViolationEvent(eventType, options.init);
|
|
372
|
-
if (eventType === "seeked")
|
|
373
|
-
return new Event(eventType, options.init);
|
|
374
|
-
if (eventType === "seeking")
|
|
375
|
-
return new Event(eventType, options.init);
|
|
376
|
-
if (eventType === "select")
|
|
377
|
-
return new Event(eventType, options.init);
|
|
378
|
-
if (eventType === "selectionchange")
|
|
379
|
-
return new Event(eventType, options.init);
|
|
380
|
-
if (eventType === "selectstart")
|
|
381
|
-
return new Event(eventType, options.init);
|
|
382
|
-
if (eventType === "stalled")
|
|
383
|
-
return new Event(eventType, options.init);
|
|
384
|
-
if (eventType === "submit")
|
|
385
|
-
return new Event(eventType, options.init);
|
|
386
|
-
if (eventType === "suspend")
|
|
387
|
-
return new Event(eventType, options.init);
|
|
388
|
-
if (eventType === "timeupdate")
|
|
389
|
-
return new Event(eventType, options.init);
|
|
390
|
-
if (eventType === "toggle")
|
|
391
|
-
return new Event(eventType, options.init);
|
|
392
|
-
if (eventType === "touchcancel")
|
|
393
|
-
return new TouchEvent(eventType, options.init);
|
|
394
|
-
if (eventType === "touchend")
|
|
395
|
-
return new TouchEvent(eventType, options.init);
|
|
396
|
-
if (eventType === "touchmove")
|
|
397
|
-
return new TouchEvent(eventType, options.init);
|
|
398
|
-
if (eventType === "touchstart")
|
|
399
|
-
return new TouchEvent(eventType, options.init);
|
|
400
|
-
if (eventType === "transitioncancel")
|
|
401
|
-
return new TransitionEvent(eventType, options.init);
|
|
402
|
-
if (eventType === "transitionend")
|
|
403
|
-
return new TransitionEvent(eventType, options.init);
|
|
404
|
-
if (eventType === "transitionrun")
|
|
405
|
-
return new TransitionEvent(eventType, options.init);
|
|
406
|
-
if (eventType === "transitionstart")
|
|
407
|
-
return new TransitionEvent(eventType, options.init);
|
|
408
|
-
if (eventType === "volumechange")
|
|
409
|
-
return new Event(eventType, options.init);
|
|
410
|
-
if (eventType === "waiting")
|
|
411
|
-
return new Event(eventType, options.init);
|
|
412
|
-
if (eventType === "wheel")
|
|
413
|
-
return new WheelEvent(eventType, options.init);
|
|
414
|
-
if (eventType === "copy")
|
|
415
|
-
return new ClipboardEvent(eventType, options.init);
|
|
416
|
-
if (eventType === "cut")
|
|
417
|
-
return new ClipboardEvent(eventType, options.init);
|
|
418
|
-
if (eventType === "paste")
|
|
419
|
-
return new ClipboardEvent(eventType, options.init);
|
|
420
|
-
if (eventType === "fullscreenchange")
|
|
421
|
-
return new Event(eventType, options.init);
|
|
422
|
-
if (eventType === "fullscreenerror")
|
|
423
|
-
return new Event(eventType, options.init);
|
|
424
|
-
if (eventType === "pointerlockchange")
|
|
425
|
-
return new Event(eventType, options.init);
|
|
426
|
-
if (eventType === "pointerlockerror")
|
|
427
|
-
return new Event(eventType, options.init);
|
|
428
|
-
if (eventType === "readystatechange")
|
|
429
|
-
return new Event(eventType, options.init);
|
|
430
|
-
if (eventType === "visibilitychange")
|
|
431
|
-
return new Event(eventType, options.init);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
197
|
function toKey(name) {
|
|
435
198
|
return name in keysByName ? keysByName[name] : name;
|
|
436
199
|
}
|
|
@@ -528,20 +291,6 @@ const modifiersByAlias = {
|
|
|
528
291
|
opt: "alt",
|
|
529
292
|
option: "alt"
|
|
530
293
|
};
|
|
531
|
-
function toModifierFlag(modifierOrAlias) {
|
|
532
|
-
return flagsByModifierOrAlias[modifierOrAlias];
|
|
533
|
-
}
|
|
534
|
-
const flagsByModifierOrAlias = {
|
|
535
|
-
shift: "shiftKey",
|
|
536
|
-
cmd: "metaKey",
|
|
537
|
-
command: "metaKey",
|
|
538
|
-
meta: "metaKey",
|
|
539
|
-
ctrl: "ctrlKey",
|
|
540
|
-
control: "ctrlKey",
|
|
541
|
-
alt: "altKey",
|
|
542
|
-
opt: "altKey",
|
|
543
|
-
option: "altKey"
|
|
544
|
-
};
|
|
545
294
|
function createExceptAndOnlyEffect(effect, options) {
|
|
546
295
|
const { except = [], only = [] } = options;
|
|
547
296
|
return (event) => {
|
|
@@ -657,7 +406,7 @@ class Recognizeable {
|
|
|
657
406
|
}
|
|
658
407
|
recognize(sequenceItem, { onRecognized } = {}) {
|
|
659
408
|
this.recognizing();
|
|
660
|
-
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(
|
|
409
|
+
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(excess)(this.sequence), [sequenceItem])([]);
|
|
661
410
|
this.effectApi.sequenceItem = sequenceItem;
|
|
662
411
|
this.effectApi.getSequence = () => newSequence;
|
|
663
412
|
this.effectApi.onRecognized = onRecognized || (() => {
|
|
@@ -1862,7 +1611,7 @@ function toInterpolated({ previous, next, progress }, options = {}) {
|
|
|
1862
1611
|
}
|
|
1863
1612
|
if (isArray(previous) && isArray(next)) {
|
|
1864
1613
|
const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
|
|
1865
|
-
return createSlice(
|
|
1614
|
+
return createSlice(0, sliceEnd)(sliceTarget);
|
|
1866
1615
|
}
|
|
1867
1616
|
}
|
|
1868
1617
|
const linear = [
|
|
@@ -2262,10 +2011,10 @@ class Copyable {
|
|
|
2262
2011
|
}
|
|
2263
2012
|
computedResponse;
|
|
2264
2013
|
computedError;
|
|
2265
|
-
async copy(options = {
|
|
2014
|
+
async copy(options = { kind: "clipboard" }) {
|
|
2266
2015
|
this.copying();
|
|
2267
|
-
const {
|
|
2268
|
-
switch (
|
|
2016
|
+
const { kind } = options;
|
|
2017
|
+
switch (kind) {
|
|
2269
2018
|
case "clipboard":
|
|
2270
2019
|
try {
|
|
2271
2020
|
this.computedResponse = await navigator.clipboard.writeText(this.string);
|
|
@@ -2453,44 +2202,6 @@ class Delayable {
|
|
|
2453
2202
|
}
|
|
2454
2203
|
}
|
|
2455
2204
|
|
|
2456
|
-
class Dispatchable {
|
|
2457
|
-
constructor(type, options = {}) {
|
|
2458
|
-
this.setType(type);
|
|
2459
|
-
this.ready();
|
|
2460
|
-
}
|
|
2461
|
-
computedStatus;
|
|
2462
|
-
ready() {
|
|
2463
|
-
this.computedStatus = "ready";
|
|
2464
|
-
}
|
|
2465
|
-
get type() {
|
|
2466
|
-
return this.computedType;
|
|
2467
|
-
}
|
|
2468
|
-
set type(type) {
|
|
2469
|
-
this.setType(type);
|
|
2470
|
-
}
|
|
2471
|
-
get cancelled() {
|
|
2472
|
-
return this.computedCancelled;
|
|
2473
|
-
}
|
|
2474
|
-
get status() {
|
|
2475
|
-
return this.computedStatus;
|
|
2476
|
-
}
|
|
2477
|
-
computedType;
|
|
2478
|
-
setType(type) {
|
|
2479
|
-
this.computedType = type;
|
|
2480
|
-
return this;
|
|
2481
|
-
}
|
|
2482
|
-
computedCancelled;
|
|
2483
|
-
dispatch(options = {}) {
|
|
2484
|
-
const { target = window, ...rest } = options, event = toEvent(this.type, rest);
|
|
2485
|
-
this.computedCancelled = !target.dispatchEvent(event);
|
|
2486
|
-
this.dispatched();
|
|
2487
|
-
return this;
|
|
2488
|
-
}
|
|
2489
|
-
dispatched() {
|
|
2490
|
-
this.computedStatus = "dispatched";
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
2205
|
const defaultOptions$3 = {
|
|
2495
2206
|
toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
|
|
2496
2207
|
};
|
|
@@ -2993,6 +2704,10 @@ class Navigateable {
|
|
|
2993
2704
|
const defaultOptions$1 = {
|
|
2994
2705
|
initialPicks: []
|
|
2995
2706
|
};
|
|
2707
|
+
const defaultPickOptions = {
|
|
2708
|
+
replace: "none",
|
|
2709
|
+
allowsDuplicates: false
|
|
2710
|
+
};
|
|
2996
2711
|
class Pickable {
|
|
2997
2712
|
constructor(array, options = {}) {
|
|
2998
2713
|
this.setArray(array);
|
|
@@ -3051,37 +2766,37 @@ class Pickable {
|
|
|
3051
2766
|
return this.pick(indexOrIndices);
|
|
3052
2767
|
}
|
|
3053
2768
|
pick(indexOrIndices, options = {}) {
|
|
3054
|
-
const { replace
|
|
2769
|
+
const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
|
|
3055
2770
|
this.computedPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks, (possiblePicks) => {
|
|
3056
2771
|
if (replace === "all") {
|
|
3057
|
-
return toUnique(possiblePicks);
|
|
2772
|
+
return allowsDuplicates ? possiblePicks : toUnique(possiblePicks);
|
|
3058
2773
|
}
|
|
3059
|
-
const
|
|
2774
|
+
const maybeWithoutDuplicates = allowsDuplicates ? possiblePicks : createFilter((possiblePick) => typeof lazyCollections.find((pick) => pick === possiblePick)(this.picks || []) !== "number")(possiblePicks);
|
|
3060
2775
|
switch (replace) {
|
|
3061
2776
|
case "none":
|
|
3062
|
-
return createConcat(this.picks || [],
|
|
2777
|
+
return createConcat(this.picks || [], maybeWithoutDuplicates)([]);
|
|
3063
2778
|
case "fifo":
|
|
3064
|
-
if (
|
|
2779
|
+
if (maybeWithoutDuplicates.length === 0) {
|
|
3065
2780
|
return this.picks;
|
|
3066
2781
|
}
|
|
3067
|
-
if (
|
|
3068
|
-
return
|
|
2782
|
+
if (maybeWithoutDuplicates.length === this.picks.length) {
|
|
2783
|
+
return maybeWithoutDuplicates;
|
|
3069
2784
|
}
|
|
3070
|
-
if (
|
|
3071
|
-
return createSlice(
|
|
2785
|
+
if (maybeWithoutDuplicates.length > this.picks.length) {
|
|
2786
|
+
return createSlice(maybeWithoutDuplicates.length - this.picks.length)(maybeWithoutDuplicates);
|
|
3072
2787
|
}
|
|
3073
|
-
return new Pipeable(this.picks).pipe(createSlice(
|
|
2788
|
+
return new Pipeable(this.picks).pipe(createSlice(maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
|
|
3074
2789
|
case "lifo":
|
|
3075
|
-
if (
|
|
2790
|
+
if (maybeWithoutDuplicates.length === 0) {
|
|
3076
2791
|
return this.picks;
|
|
3077
2792
|
}
|
|
3078
|
-
if (
|
|
3079
|
-
return
|
|
2793
|
+
if (maybeWithoutDuplicates.length === this.picks.length) {
|
|
2794
|
+
return maybeWithoutDuplicates;
|
|
3080
2795
|
}
|
|
3081
|
-
if (
|
|
3082
|
-
return createSlice(
|
|
2796
|
+
if (maybeWithoutDuplicates.length > this.picks.length) {
|
|
2797
|
+
return createSlice(0, maybeWithoutDuplicates.length - this.picks.length + 1)(maybeWithoutDuplicates);
|
|
3083
2798
|
}
|
|
3084
|
-
return new Pipeable(this.picks).pipe(createSlice(
|
|
2799
|
+
return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - maybeWithoutDuplicates.length), createConcat(maybeWithoutDuplicates));
|
|
3085
2800
|
}
|
|
3086
2801
|
});
|
|
3087
2802
|
this.computedFirst = Math.min(...this.picks);
|
|
@@ -3092,7 +2807,7 @@ class Pickable {
|
|
|
3092
2807
|
picked() {
|
|
3093
2808
|
this.computedStatus = "picked";
|
|
3094
2809
|
}
|
|
3095
|
-
omit(indexOrIndices) {
|
|
2810
|
+
omit(indexOrIndices, options = { reference: "array" }) {
|
|
3096
2811
|
if (isUndefined(indexOrIndices)) {
|
|
3097
2812
|
this.computedPicks = [];
|
|
3098
2813
|
this.computedFirst = void 0;
|
|
@@ -3101,7 +2816,7 @@ class Pickable {
|
|
|
3101
2816
|
return this;
|
|
3102
2817
|
}
|
|
3103
2818
|
const omits = ensureIndices(indexOrIndices);
|
|
3104
|
-
this.computedPicks = createFilter((pick) => isUndefined(lazyCollections.find((omit) => pick === omit)(omits)))(this.computedPicks);
|
|
2819
|
+
this.computedPicks = createFilter((pick, index) => options.reference === "array" ? isUndefined(lazyCollections.find((omit) => pick === omit)(omits)) : isUndefined(lazyCollections.find((omit) => index === omit)(omits)))(this.computedPicks);
|
|
3105
2820
|
this.computedFirst = Math.min(...this.picks);
|
|
3106
2821
|
this.computedLast = Math.max(...this.picks);
|
|
3107
2822
|
this.omitted();
|
|
@@ -3209,15 +2924,15 @@ class Searchable {
|
|
|
3209
2924
|
}
|
|
3210
2925
|
|
|
3211
2926
|
const defaultOptions = {
|
|
3212
|
-
|
|
2927
|
+
kind: "local",
|
|
3213
2928
|
statusKeySuffix: " status"
|
|
3214
2929
|
};
|
|
3215
2930
|
class Storeable {
|
|
3216
|
-
|
|
2931
|
+
kind;
|
|
3217
2932
|
statusKeySuffix;
|
|
3218
2933
|
constructor(key, options = {}) {
|
|
3219
2934
|
this.constructing();
|
|
3220
|
-
this.
|
|
2935
|
+
this.kind = options.kind ?? defaultOptions.kind;
|
|
3221
2936
|
this.statusKeySuffix = options.statusKeySuffix ?? defaultOptions.statusKeySuffix;
|
|
3222
2937
|
this.setKey(key);
|
|
3223
2938
|
this.ready();
|
|
@@ -3250,7 +2965,7 @@ class Storeable {
|
|
|
3250
2965
|
return this.computedStatus;
|
|
3251
2966
|
}
|
|
3252
2967
|
get storage() {
|
|
3253
|
-
switch (this.
|
|
2968
|
+
switch (this.kind) {
|
|
3254
2969
|
case "local":
|
|
3255
2970
|
return localStorage;
|
|
3256
2971
|
case "session":
|
|
@@ -3333,7 +3048,6 @@ exports.Animateable = Animateable;
|
|
|
3333
3048
|
exports.Completeable = Completeable;
|
|
3334
3049
|
exports.Copyable = Copyable;
|
|
3335
3050
|
exports.Delayable = Delayable;
|
|
3336
|
-
exports.Dispatchable = Dispatchable;
|
|
3337
3051
|
exports.Drawable = Drawable;
|
|
3338
3052
|
exports.Fetchable = Fetchable;
|
|
3339
3053
|
exports.Fullscreenable = Fullscreenable;
|