@baleada/logic 0.22.4 → 0.22.5

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { reduce, pipe, unique, toArray, slice, filter, map, concat, find, findIndex, some, every, join } from 'lazy-collections';
1
+ import { reduce, pipe, unique, toArray, slice, filter, map, concat, find, findIndex, join, some, every } from 'lazy-collections';
2
2
  import slugify from '@sindresorhus/slugify';
3
3
  import BezierEasing from 'bezier-easing';
4
4
  import { mix } from '@snigo.dev/color';
@@ -45,7 +45,7 @@ function createFilterAsync(condition) {
45
45
  return createFilter((_, index) => transformedAsync[index])(array);
46
46
  };
47
47
  }
48
- function createDelete(index) {
48
+ function createRemove(index) {
49
49
  return (array) => {
50
50
  return createConcat(
51
51
  createSlice(0, index)(array),
@@ -64,7 +64,7 @@ function createInsert(item, index) {
64
64
  }
65
65
  function createReorder(from, to) {
66
66
  return (array) => {
67
- const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
67
+ const [itemsToMoveStartIndex, itemsToMoveCount] = predicateObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
68
68
  if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
69
69
  return array;
70
70
  }
@@ -90,7 +90,7 @@ function createReorder(from, to) {
90
90
  return array;
91
91
  };
92
92
  }
93
- function isObject(value) {
93
+ function predicateObject(value) {
94
94
  return typeof value === "object";
95
95
  }
96
96
  function createSwap(indices) {
@@ -218,6 +218,37 @@ function createToEntries() {
218
218
  return entries;
219
219
  };
220
220
  }
221
+ function createMatchesKeycombo(keycombo) {
222
+ return (event) => eventMatchesKeycombo(event, narrowKeycombo(keycombo));
223
+ }
224
+ function createMatchesMousecombo(mousecombo) {
225
+ return (event) => eventMatchesMousecombo(event, narrowMousecombo(mousecombo));
226
+ }
227
+ function createMatchesPointercombo(pointercombo) {
228
+ return (event) => eventMatchesPointercombo(event, narrowPointercombo(pointercombo));
229
+ }
230
+ function createToFocusable(order, elementIsCandidate) {
231
+ return (element) => {
232
+ if (elementIsCandidate && predicateFocusable(element))
233
+ return element;
234
+ switch (order) {
235
+ case "first":
236
+ for (let i = 0; i < element.children.length; i++) {
237
+ const focusable = createToFocusable(order, true)(element.children[i]);
238
+ if (focusable)
239
+ return focusable;
240
+ }
241
+ break;
242
+ case "last":
243
+ for (let i = element.children.length - 1; i > -1; i--) {
244
+ const focusable = createToFocusable(order, true)(element.children[i]);
245
+ if (focusable)
246
+ return focusable;
247
+ }
248
+ break;
249
+ }
250
+ };
251
+ }
221
252
  class Pipeable {
222
253
  constructor(state) {
223
254
  this.state = state;
@@ -285,16 +316,16 @@ const keysByName = {
285
316
  f20: "F20"
286
317
  };
287
318
  const toListenableKeycomboItems = createMap((name) => ({ name, type: fromComboItemNameToType(name) }));
288
- function ensureKeycombo(type) {
319
+ function narrowKeycombo(type) {
289
320
  return new Pipeable(type).pipe(
290
321
  toCombo,
291
322
  toListenableKeycomboItems
292
323
  );
293
324
  }
294
- function ensureClickcombo(type) {
325
+ function narrowMousecombo(type) {
295
326
  return toCombo(type);
296
327
  }
297
- function ensurePointercombo(type) {
328
+ function narrowPointercombo(type) {
298
329
  return toCombo(type);
299
330
  }
300
331
  const toUnique$1 = unique();
@@ -341,45 +372,39 @@ function createExceptAndOnlyEffect(type, effect, options) {
341
372
  const { except = [], only = [] } = options;
342
373
  if (type === "keydown" || type === "keyup") {
343
374
  return (event) => {
344
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
345
- matches: (keycombo) => eventMatchesKeycombo(event, ensureKeycombo(keycombo))
346
- };
375
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
347
376
  if (matchesOnly) {
348
- effect(event, api);
377
+ effect(event);
349
378
  return;
350
379
  }
351
380
  if (only.length === 0 && !matchesExcept) {
352
- effect(event, api);
381
+ effect(event);
353
382
  return;
354
383
  }
355
384
  };
356
385
  }
357
386
  if (type === "click" || type === "dblclick" || type === "contextmenu" || type.startsWith("mouse")) {
358
387
  return (event) => {
359
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
360
- matches: (clickcombo) => eventMatchesClickcombo(event, ensureClickcombo(clickcombo))
361
- };
388
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
362
389
  if (matchesOnly) {
363
- effect(event, api);
390
+ effect(event);
364
391
  return;
365
392
  }
366
393
  if (only.length === 0 && !matchesExcept) {
367
- effect(event, api);
394
+ effect(event);
368
395
  return;
369
396
  }
370
397
  };
371
398
  }
372
399
  if (type.startsWith("pointer")) {
373
400
  return (event) => {
374
- const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true], api = {
375
- matches: (pointercombo) => eventMatchesPointercombo(event, ensurePointercombo(pointercombo))
376
- };
401
+ const { target } = event, [matchesOnly, matchesExcept] = target instanceof Element ? createMap((selectors) => some((selector) => target.matches(selector))(selectors))([only, except]) : [false, true];
377
402
  if (matchesOnly) {
378
- effect(event, api);
403
+ effect(event);
379
404
  return;
380
405
  }
381
406
  if (only.length === 0 && !matchesExcept) {
382
- effect(event, api);
407
+ effect(event);
383
408
  return;
384
409
  }
385
410
  };
@@ -396,7 +421,7 @@ function createExceptAndOnlyEffect(type, effect, options) {
396
421
  }
397
422
  };
398
423
  }
399
- function isModified({ event, alias }) {
424
+ function predicateModified({ event, alias }) {
400
425
  return predicatesByModifier[alias]?.(event);
401
426
  }
402
427
  const predicatesByModifier = {
@@ -417,24 +442,43 @@ function domIsAvailable() {
417
442
  return false;
418
443
  }
419
444
  }
420
- function isArray(value) {
445
+ function predicateArray(value) {
421
446
  return Array.isArray(value);
422
447
  }
423
- function isUndefined(value) {
448
+ function predicateUndefined(value) {
424
449
  return value === void 0;
425
450
  }
426
- function isFunction(value) {
451
+ function predicateFunction(value) {
427
452
  return typeof value === "function";
428
453
  }
429
- function isNull(value) {
454
+ function predicateNull(value) {
430
455
  return value === null;
431
456
  }
432
- function isNumber(value) {
457
+ function predicateNumber(value) {
433
458
  return typeof value === "number";
434
459
  }
435
- function isString(value) {
460
+ function predicateString(value) {
436
461
  return typeof value === "string";
437
462
  }
463
+ const tabbableSelector = join(':not([hidden]):not([tabindex="-1"]),')([
464
+ "input:not([disabled]):not([type=hidden])",
465
+ "select:not([disabled])",
466
+ "textarea:not([disabled])",
467
+ "button:not([disabled])",
468
+ "a[href]",
469
+ "area[href]",
470
+ "summary",
471
+ "iframe",
472
+ "object",
473
+ "embed",
474
+ "audio[controls]",
475
+ "video[controls]",
476
+ "[contenteditable]",
477
+ "[tabindex]:not([disabled])"
478
+ ]);
479
+ function predicateFocusable(element) {
480
+ return element.matches(tabbableSelector);
481
+ }
438
482
 
439
483
  class Recognizeable {
440
484
  maxSequenceLength;
@@ -489,16 +533,16 @@ class Recognizeable {
489
533
  this.computedSequence = sequence;
490
534
  return this;
491
535
  }
492
- recognize(sequenceItem, api, { onRecognized } = {}) {
536
+ recognize(sequenceItem, { onRecognized } = {}) {
493
537
  this.recognizing();
494
- const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
538
+ const type = this.toType(sequenceItem), excess = predicateNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(
495
539
  createSlice(excess)(this.sequence),
496
540
  [sequenceItem]
497
541
  )([]);
498
542
  this.effectApi.getSequence = () => newSequence;
499
543
  this.effectApi.onRecognized = onRecognized || (() => {
500
544
  });
501
- this.effects.get(type)?.(sequenceItem, { ...api, ...this.effectApi });
545
+ this.effects.get(type)?.(sequenceItem, { ...this.effectApi });
502
546
  switch (this.status) {
503
547
  case "denied":
504
548
  this.resetComputedMetadata();
@@ -515,7 +559,7 @@ class Recognizeable {
515
559
  this.computedStatus = "recognizing";
516
560
  }
517
561
  toType(sequenceItem) {
518
- if (isArray(sequenceItem)) {
562
+ if (predicateArray(sequenceItem)) {
519
563
  if (sequenceItem[0] instanceof IntersectionObserverEntry) {
520
564
  return "intersect";
521
565
  }
@@ -627,27 +671,27 @@ class Listenable {
627
671
  }
628
672
  mediaQueryListen(effect, options) {
629
673
  const target = window.matchMedia(this.type);
630
- if (isFunction(options.instantEffect)) {
674
+ if (predicateFunction(options.instantEffect)) {
631
675
  options.instantEffect(target);
632
676
  }
633
- const withApi = (event) => effect(event, {});
677
+ const withApi = (event) => effect(event);
634
678
  target.addEventListener("change", withApi);
635
679
  this.active.add({ target, id: ["change", withApi] });
636
680
  }
637
681
  idleListen(effect, options) {
638
- const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline, {}), requestIdleCallback);
682
+ const { requestIdleCallback } = options, id = window.requestIdleCallback((deadline) => effect(deadline), requestIdleCallback);
639
683
  this.active.add({ target: window, id });
640
684
  }
641
685
  messageListen(effect, options) {
642
686
  const { target = new BroadcastChannel("baleada") } = options;
643
- target.addEventListener(this.type, (event) => effect(event, {}));
687
+ target.addEventListener(this.type, (event) => effect(event));
644
688
  this.active.add({ target, id: [this.type, effect] });
645
689
  }
646
690
  recognizeableListen(effect, options) {
647
- const guardedEffect = (sequenceItem, api) => {
648
- this.recognizeable.recognize(sequenceItem, api, { onRecognized: (sequenceItem2) => effect(sequenceItem2, api) });
691
+ const guardedEffect = (sequenceItem) => {
692
+ this.recognizeable.recognize(sequenceItem, { onRecognized: (sequenceItem2) => effect(sequenceItem2) });
649
693
  if (this.recognizeable.status === "recognized") {
650
- effect(sequenceItem, api);
694
+ effect(sequenceItem);
651
695
  }
652
696
  };
653
697
  for (const type of this.recognizeableEffectsKeys) {
@@ -657,11 +701,11 @@ class Listenable {
657
701
  }
658
702
  }
659
703
  documentEventListen(effect, options) {
660
- const ensuredOptions = {
704
+ const narrowedOptions = {
661
705
  ...options,
662
706
  target: document
663
707
  };
664
- this.eventListen(effect, ensuredOptions);
708
+ this.eventListen(effect, narrowedOptions);
665
709
  }
666
710
  eventListen(effect, options) {
667
711
  const { exceptAndOnlyEffect, effectOptions } = toAddEventListenerParams(this.type, effect, options), eventListeners = [[this.type, exceptAndOnlyEffect, ...effectOptions]];
@@ -715,7 +759,7 @@ function stop(stoppable) {
715
759
  target2.removeEventListener(id2[0], id2[1]);
716
760
  return;
717
761
  }
718
- if (isNumber(stoppable.id)) {
762
+ if (predicateNumber(stoppable.id)) {
719
763
  const { target: target2, id: id2 } = stoppable;
720
764
  target2.cancelIdleCallback(id2);
721
765
  return;
@@ -804,7 +848,7 @@ function eventMatchesKeycombo(event, keycombo) {
804
848
  if (index === keycombo.length - 1) {
805
849
  return name.startsWith("!") ? event.key.toLowerCase() !== toModifier(name.slice(1)).toLowerCase() : event.key.toLowerCase() === toModifier(name).toLowerCase();
806
850
  }
807
- return name.startsWith("!") ? !isModified({ event, alias: name.slice(1) }) : isModified({ event, alias: name });
851
+ return name.startsWith("!") ? !predicateModified({ event, alias: name.slice(1) }) : predicateModified({ event, alias: name });
808
852
  }
809
853
  })(keycombo);
810
854
  }
@@ -868,11 +912,11 @@ const predicatesByArrow = /* @__PURE__ */ new Map([
868
912
  const arrows = /* @__PURE__ */ new Set(["arrowup", "arrowright", "arrowdown", "arrowleft"]);
869
913
  const verticalArrows = /* @__PURE__ */ new Set(["arrowup", "arrowdown"]);
870
914
  const horizontalArrows = /* @__PURE__ */ new Set(["arrowright", "arrowleft"]);
871
- function eventMatchesClickcombo(event, clickcombo) {
872
- return every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(clickcombo);
915
+ function eventMatchesMousecombo(event, Mousecombo) {
916
+ return every((name) => fromComboItemNameToType(name) === "click" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(Mousecombo);
873
917
  }
874
918
  function eventMatchesPointercombo(event, pointercombo) {
875
- return every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !isModified({ alias: name.slice(1), event }) || !name.startsWith("!") && isModified({ alias: name, event }))(pointercombo);
919
+ return every((name) => fromComboItemNameToType(name) === "pointer" || name.startsWith("!") && !predicateModified({ alias: name.slice(1), event }) || !name.startsWith("!") && predicateModified({ alias: name, event }))(pointercombo);
876
920
  }
877
921
  const observerAssertionsByType = {
878
922
  intersect: (observer) => observer instanceof IntersectionObserver,
@@ -1000,13 +1044,13 @@ class Animateable {
1000
1044
  duration;
1001
1045
  totalTimeInvisible;
1002
1046
  setPlaybackRate(playbackRate) {
1003
- const ensuredPlaybackRate = Math.max(0, playbackRate);
1004
- this.computedPlaybackRate = ensuredPlaybackRate;
1005
- this.duration = 1 / ensuredPlaybackRate * this.initialDuration;
1047
+ const narrowedPlaybackRate = Math.max(0, playbackRate);
1048
+ this.computedPlaybackRate = narrowedPlaybackRate;
1049
+ this.duration = 1 / narrowedPlaybackRate * this.initialDuration;
1006
1050
  switch (this.status) {
1007
1051
  case "playing":
1008
1052
  case "reversing":
1009
- this.totalTimeInvisible = 1 / ensuredPlaybackRate * this.totalTimeInvisible;
1053
+ this.totalTimeInvisible = 1 / narrowedPlaybackRate * this.totalTimeInvisible;
1010
1054
  this.seek(this.progress.time);
1011
1055
  break;
1012
1056
  }
@@ -1395,51 +1439,51 @@ class Animateable {
1395
1439
  seek(timeProgress, options = {}) {
1396
1440
  const iterations = Math.floor(timeProgress), naiveIterationProgress = timeProgress - iterations, { effect: naiveEffect } = options;
1397
1441
  this.computedIterations = iterations;
1398
- let ensuredTimeProgress, effect;
1442
+ let narrowedTimeProgress, effect;
1399
1443
  if (this.alternates) {
1400
1444
  if (naiveIterationProgress <= 0.5) {
1401
- ensuredTimeProgress = naiveIterationProgress * 2;
1445
+ narrowedTimeProgress = naiveIterationProgress * 2;
1402
1446
  switch (this.alternateCache.status) {
1403
1447
  case "playing":
1404
1448
  this.cancelAnimate();
1405
- this.seekCache = { timeProgress: ensuredTimeProgress };
1449
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1406
1450
  this.sought();
1407
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1451
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1408
1452
  this.play(effect, this.playCache.options);
1409
1453
  break;
1410
1454
  case "reversing":
1411
1455
  this.cancelAnimate();
1412
- this.seekCache = { timeProgress: ensuredTimeProgress };
1456
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1413
1457
  this.sought();
1414
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1458
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1415
1459
  this.reverse(effect, this.reverseCache.options);
1416
1460
  break;
1417
1461
  default:
1418
- this.seekCache = { timeProgress: ensuredTimeProgress };
1462
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1419
1463
  this.sought();
1420
1464
  effect = naiveEffect;
1421
1465
  this.createAnimate("seek")(effect, options);
1422
1466
  break;
1423
1467
  }
1424
1468
  } else {
1425
- ensuredTimeProgress = (naiveIterationProgress - 0.5) * 2;
1469
+ narrowedTimeProgress = (naiveIterationProgress - 0.5) * 2;
1426
1470
  switch (this.alternateCache.status) {
1427
1471
  case "playing":
1428
1472
  this.cancelAnimate();
1429
- this.seekCache = { timeProgress: ensuredTimeProgress };
1473
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1430
1474
  this.sought();
1431
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1475
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1432
1476
  this.reverse(effect, this.reverseCache.options);
1433
1477
  break;
1434
1478
  case "reversing":
1435
1479
  this.cancelAnimate();
1436
- this.seekCache = { timeProgress: ensuredTimeProgress };
1480
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1437
1481
  this.sought();
1438
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1482
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1439
1483
  this.play(effect, this.playCache.options);
1440
1484
  break;
1441
1485
  default:
1442
- this.seekCache = { timeProgress: ensuredTimeProgress };
1486
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1443
1487
  this.sought();
1444
1488
  effect = naiveEffect;
1445
1489
  if (effect) {
@@ -1449,24 +1493,24 @@ class Animateable {
1449
1493
  }
1450
1494
  }
1451
1495
  } else {
1452
- ensuredTimeProgress = naiveIterationProgress;
1496
+ narrowedTimeProgress = naiveIterationProgress;
1453
1497
  switch (this.status) {
1454
1498
  case "playing":
1455
1499
  this.cancelAnimate();
1456
- this.seekCache = { timeProgress: ensuredTimeProgress };
1500
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1457
1501
  this.sought();
1458
- effect = isFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1502
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.playCache.effect;
1459
1503
  this.play(effect, this.playCache.options);
1460
1504
  break;
1461
1505
  case "reversing":
1462
1506
  this.cancelAnimate();
1463
- this.seekCache = { timeProgress: ensuredTimeProgress };
1507
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1464
1508
  this.sought();
1465
- effect = isFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1509
+ effect = predicateFunction(naiveEffect) ? naiveEffect : this.reverseCache.effect;
1466
1510
  this.reverse(effect, this.reverseCache.options);
1467
1511
  break;
1468
1512
  default:
1469
- this.seekCache = { timeProgress: ensuredTimeProgress };
1513
+ this.seekCache = { timeProgress: narrowedTimeProgress };
1470
1514
  this.sought();
1471
1515
  effect = naiveEffect;
1472
1516
  if (effect) {
@@ -1592,13 +1636,13 @@ function createToAnimationProgress(points) {
1592
1636
  return BezierEasing(point1x, point1y, point2x, point2y);
1593
1637
  }
1594
1638
  function toInterpolated({ previous, next, progress }, options = {}) {
1595
- if (isUndefined(previous)) {
1639
+ if (predicateUndefined(previous)) {
1596
1640
  return next;
1597
1641
  }
1598
- if (isNumber(previous) && isNumber(next)) {
1642
+ if (predicateNumber(previous) && predicateNumber(next)) {
1599
1643
  return (next - previous) * progress + previous;
1600
1644
  }
1601
- if (isString(previous) && isString(next)) {
1645
+ if (predicateString(previous) && predicateString(next)) {
1602
1646
  return mix(
1603
1647
  options.colorModel,
1604
1648
  {
@@ -1608,7 +1652,7 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1608
1652
  }
1609
1653
  ).toRgb().toRgbString();
1610
1654
  }
1611
- if (isArray(previous) && isArray(next)) {
1655
+ if (predicateArray(previous) && predicateArray(next)) {
1612
1656
  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;
1613
1657
  return createSlice(0, sliceEnd)(sliceTarget);
1614
1658
  }
@@ -1974,7 +2018,7 @@ class Completeable {
1974
2018
  complete(completion, options = {}) {
1975
2019
  this.completing();
1976
2020
  const { select } = { ...defaultCompleteOptions, ...options }, before = this.getBefore(), after = this.getAfter(), completedString = before + completion + after, completedSelection = (() => {
1977
- if (isFunction(select)) {
2021
+ if (predicateFunction(select)) {
1978
2022
  return select({ before, completion, after });
1979
2023
  }
1980
2024
  switch (select) {
@@ -2379,7 +2423,7 @@ class Resolveable {
2379
2423
  this.resolving();
2380
2424
  try {
2381
2425
  const promises = this.getPromise(...args);
2382
- this.computedValue = isArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2426
+ this.computedValue = predicateArray(promises) ? await createMapAsync(async (promise) => await promise)(promises) : await promises;
2383
2427
  this.resolved();
2384
2428
  } catch (error) {
2385
2429
  this.computedValue = error;
@@ -2464,7 +2508,7 @@ class Fetchable {
2464
2508
  async fetch(options = {}) {
2465
2509
  this.fetching();
2466
2510
  try {
2467
- this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...ensureOptions(options) });
2511
+ this.computedResponse = await fetch(this.resource, { signal: this.abortController.signal, ...narrowOptions(options) });
2468
2512
  this.fetched();
2469
2513
  } catch (error) {
2470
2514
  this.computedError = error;
@@ -2488,23 +2532,23 @@ class Fetchable {
2488
2532
  this.computedStatus = "errored";
2489
2533
  }
2490
2534
  async get(options = {}) {
2491
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "get" });
2535
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "get" });
2492
2536
  return this;
2493
2537
  }
2494
2538
  async patch(options = {}) {
2495
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "patch" });
2539
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "patch" });
2496
2540
  return this;
2497
2541
  }
2498
2542
  async post(options = {}) {
2499
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "post" });
2543
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "post" });
2500
2544
  return this;
2501
2545
  }
2502
2546
  async put(options = {}) {
2503
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "put" });
2547
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "put" });
2504
2548
  return this;
2505
2549
  }
2506
2550
  async delete(options = {}) {
2507
- await this.fetch({ signal: this.abortController.signal, ...ensureOptions(options), method: "delete" });
2551
+ await this.fetch({ signal: this.abortController.signal, ...narrowOptions(options), method: "delete" });
2508
2552
  return this;
2509
2553
  }
2510
2554
  abort() {
@@ -2512,8 +2556,8 @@ class Fetchable {
2512
2556
  return this;
2513
2557
  }
2514
2558
  }
2515
- function ensureOptions(options) {
2516
- return isFunction(options) ? options({ withJson }) : options;
2559
+ function narrowOptions(options) {
2560
+ return predicateFunction(options) ? options({ withJson }) : options;
2517
2561
  }
2518
2562
  function withJson(data) {
2519
2563
  return {
@@ -2696,7 +2740,7 @@ class Navigateable {
2696
2740
  }
2697
2741
  _navigate(location, options = {}) {
2698
2742
  const { allow } = { ...defaultNavigateOptions, ...options };
2699
- const ensuredLocation = (() => {
2743
+ const narrowedLocation = (() => {
2700
2744
  if (allow === "possible") {
2701
2745
  if (location < 0 && allow === "possible") {
2702
2746
  return 0;
@@ -2707,7 +2751,7 @@ class Navigateable {
2707
2751
  }
2708
2752
  return location;
2709
2753
  })();
2710
- this.computedLocation = ensuredLocation;
2754
+ this.computedLocation = narrowedLocation;
2711
2755
  }
2712
2756
  next(options = {}) {
2713
2757
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
@@ -2851,7 +2895,7 @@ class Pickable {
2851
2895
  pick(indexOrIndices, options = {}) {
2852
2896
  const { replace, allowsDuplicates } = { ...defaultPickOptions, ...options };
2853
2897
  this.computedPicks = new Pipeable(indexOrIndices).pipe(
2854
- ensureIndices,
2898
+ narrowIndices,
2855
2899
  this.toPossiblePicks,
2856
2900
  (possiblePicks) => {
2857
2901
  if (replace === "all") {
@@ -2904,7 +2948,7 @@ class Pickable {
2904
2948
  this.computedStatus = "picked";
2905
2949
  }
2906
2950
  omit(indexOrIndices, options = { reference: "array" }) {
2907
- if (isUndefined(indexOrIndices)) {
2951
+ if (predicateUndefined(indexOrIndices)) {
2908
2952
  this.computedPicks = [];
2909
2953
  this.computedFirst = void 0;
2910
2954
  this.computedLast = void 0;
@@ -2912,9 +2956,9 @@ class Pickable {
2912
2956
  this.omitted();
2913
2957
  return this;
2914
2958
  }
2915
- const omits = ensureIndices(indexOrIndices);
2959
+ const omits = narrowIndices(indexOrIndices);
2916
2960
  this.computedPicks = createFilter(
2917
- (pick, index) => options.reference === "array" ? isUndefined(find((omit) => pick === omit)(omits)) : isUndefined(find((omit) => index === omit)(omits))
2961
+ (pick, index) => options.reference === "array" ? predicateUndefined(find((omit) => pick === omit)(omits)) : predicateUndefined(find((omit) => index === omit)(omits))
2918
2962
  )(this.computedPicks);
2919
2963
  this.computedFirst = Math.min(...this.picks);
2920
2964
  this.computedLast = Math.max(...this.picks);
@@ -2926,7 +2970,7 @@ class Pickable {
2926
2970
  this.computedStatus = "omitted";
2927
2971
  }
2928
2972
  }
2929
- function ensureIndices(indexOrIndices) {
2973
+ function narrowIndices(indexOrIndices) {
2930
2974
  return Array.isArray(indexOrIndices) ? indexOrIndices : [indexOrIndices];
2931
2975
  }
2932
2976
  const toUnique = createUnique();
@@ -3098,7 +3142,7 @@ class Storeable {
3098
3142
  ready() {
3099
3143
  this.computedStatus = "ready";
3100
3144
  if (domIsAvailable()) {
3101
- if (isNull(this.storage.getItem(this.computedStatusKey))) {
3145
+ if (predicateNull(this.storage.getItem(this.computedStatusKey))) {
3102
3146
  this.storeStatus();
3103
3147
  }
3104
3148
  }
@@ -3112,7 +3156,7 @@ class Storeable {
3112
3156
  get status() {
3113
3157
  if (domIsAvailable()) {
3114
3158
  const storedStatus = this.storage.getItem(this.computedStatusKey);
3115
- if (this.computedStatus !== storedStatus && isString(storedStatus)) {
3159
+ if (this.computedStatus !== storedStatus && predicateString(storedStatus)) {
3116
3160
  this.computedStatus = storedStatus;
3117
3161
  }
3118
3162
  }
@@ -3198,4 +3242,4 @@ class Storeable {
3198
3242
  }
3199
3243
  }
3200
3244
 
3201
- export { Animateable, Broadcastable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
3245
+ export { Animateable, Broadcastable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Shareable, Storeable, createClamp, createClip, createConcat, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createMatchesKeycombo, createMatchesMousecombo, createMatchesPointercombo, createReduce, createReduceAsync, createRemove, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createToFocusable, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, toMessageListenParams, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.22.4",
3
+ "version": "0.22.5",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",
@@ -51,7 +51,7 @@
51
51
  "rollup": "^3.2.5",
52
52
  "tslib": "^2.4.1",
53
53
  "typescript": "^4.8.4",
54
- "uvu": "^0.5.1",
54
+ "uvu": "^0.5.6",
55
55
  "vite": "^3.2.5",
56
56
  "vue": "^3.2.45",
57
57
  "vue-router": "^4.1.6"