@baleada/logic 0.20.34 → 0.21.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/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(required) {
53
+ function createDelete(index) {
54
54
  return (array) => {
55
- const deleteIndex = "index" in required ? required.index : lazyCollections.findIndex((element) => element === required?.item)(array);
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(required) {
58
+ function createInsert(item, index) {
60
59
  return (array) => {
61
- const itemsToInsert = "items" in required ? required.items : [required.item], withItems = createConcat(array, itemsToInsert)([]);
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({ from, to }) {
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({ from: itemsToMoveStartIndex, to: itemsToMoveStartIndex + itemsToMoveCount })(array);
70
+ const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
75
71
  if (itemsToMoveStartIndex < insertIndex) {
76
- const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice({ from: 0, to: itemsToMoveStartIndex })(array), betweenItemsToMoveAndInsertIndex = createSlice({ from: itemsToMoveStartIndex + itemsToMoveCount, to: insertIndex + 1 })(array), afterInsertIndex = createSlice({ from: insertIndex + 1 })(array);
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({ from: 0, to: insertIndex })(array), betweenInsertionAndItemsToMove = createSlice({ from: insertIndex, to: itemsToMoveStartIndex })(array), afterItemsToMove = createSlice({ from: itemsToMoveStartIndex + itemsToMoveCount })(array);
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({ indices }) {
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({ from, to }),
95
- reorderTo: createReorder({ from: to - 1, to: from })
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({ from, to }),
101
- reorderTo: createReorder({ from: to + 1, to: from })
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({ index, item }) {
108
+ function createReplace(index, item) {
113
109
  return (array) => {
114
- return createConcat(createSlice({ from: 0, to: index })(array), [item], createSlice({ from: index + 1 })(array))([]);
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({ from, to }) {
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({ from: 0 }), (sliced) => sliced.sort(compare));
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({ min, max }) {
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({ from, to }) {
170
+ function createRename(from, to) {
175
171
  return (map2) => {
176
- const keys = [...map2.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace({ index: keyToRenameIndex, item: to })(keys), values = [...map2.values()];
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
  }
@@ -202,7 +198,7 @@ function toEvent(eventType, options) {
202
198
  const implementation = toImplementation(eventType);
203
199
  switch (implementation) {
204
200
  case "keycombo": {
205
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
201
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
206
202
  return new KeyboardEvent("keyDirection" in options ? `key${options.keyDirection}` : "keydown", {
207
203
  ...options.init || {},
208
204
  key: toKey(name),
@@ -214,7 +210,7 @@ function toEvent(eventType, options) {
214
210
  }
215
211
  case "leftclickcombo":
216
212
  case "rightclickcombo": {
217
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
213
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
218
214
  return new MouseEvent(name === "rightclick" ? "contextmenu" : name, {
219
215
  ...options.init || {},
220
216
  ...createReduce((flags, alias) => {
@@ -224,7 +220,7 @@ function toEvent(eventType, options) {
224
220
  });
225
221
  }
226
222
  case "pointercombo": {
227
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
223
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
228
224
  return new PointerEvent(name === "rightclick" ? "contextmenu" : name, {
229
225
  ...options.init || {},
230
226
  ...createReduce((flags, alias) => {
@@ -657,7 +653,7 @@ class Recognizeable {
657
653
  }
658
654
  recognize(sequenceItem, { onRecognized } = {}) {
659
655
  this.recognizing();
660
- const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice({ from: excess })(this.sequence), [sequenceItem])([]);
656
+ 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
657
  this.effectApi.sequenceItem = sequenceItem;
662
658
  this.effectApi.getSequence = () => newSequence;
663
659
  this.effectApi.onRecognized = onRecognized || (() => {
@@ -1862,7 +1858,7 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1862
1858
  }
1863
1859
  if (isArray(previous) && isArray(next)) {
1864
1860
  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({ from: 0, to: sliceEnd })(sliceTarget);
1861
+ return createSlice(0, sliceEnd)(sliceTarget);
1866
1862
  }
1867
1863
  }
1868
1864
  const linear = [
@@ -3068,9 +3064,9 @@ class Pickable {
3068
3064
  return possibleWithoutDuplicates;
3069
3065
  }
3070
3066
  if (possibleWithoutDuplicates.length > this.picks.length) {
3071
- return createSlice({ from: possibleWithoutDuplicates.length - this.picks.length })(possibleWithoutDuplicates);
3067
+ return createSlice(possibleWithoutDuplicates.length - this.picks.length)(possibleWithoutDuplicates);
3072
3068
  }
3073
- return new Pipeable(this.picks).pipe(createSlice({ from: possibleWithoutDuplicates.length }), createConcat(possibleWithoutDuplicates));
3069
+ return new Pipeable(this.picks).pipe(createSlice(possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
3074
3070
  case "lifo":
3075
3071
  if (possibleWithoutDuplicates.length === 0) {
3076
3072
  return this.picks;
@@ -3079,9 +3075,9 @@ class Pickable {
3079
3075
  return possibleWithoutDuplicates;
3080
3076
  }
3081
3077
  if (possibleWithoutDuplicates.length > this.picks.length) {
3082
- return createSlice({ from: 0, to: possibleWithoutDuplicates.length - this.picks.length + 1 })(possibleWithoutDuplicates);
3078
+ return createSlice(0, possibleWithoutDuplicates.length - this.picks.length + 1)(possibleWithoutDuplicates);
3083
3079
  }
3084
- return new Pipeable(this.picks).pipe(createSlice({ from: 0, to: this.picks.length - possibleWithoutDuplicates.length }), createConcat(possibleWithoutDuplicates));
3080
+ return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
3085
3081
  }
3086
3082
  });
3087
3083
  this.computedFirst = Math.min(...this.picks);
package/lib/index.d.ts CHANGED
@@ -852,37 +852,16 @@ declare function createForEachAsync<Item>(forEach: (item?: Item, index?: number)
852
852
  declare function createMapAsync<Item, Mapped>(transform: (item?: Item, index?: number) => Promise<Mapped>): ArrayFunctionAsync<Item, Mapped[]>;
853
853
  declare function createFilterAsync<Item>(condition: (item?: Item, index?: number) => Promise<boolean>): ArrayFunctionAsync<Item, Item[]>;
854
854
  declare type ArrayFunction<Item, Returned> = (array: Item[]) => Returned;
855
- declare function createDelete<Item>(required: {
856
- index: number;
857
- } | {
858
- item: Item;
859
- }): ArrayFunction<Item, Item[]>;
860
- declare function createInsert<Item>(required: ({
861
- item: Item;
862
- } | {
863
- items: Item[];
864
- }) & {
865
- index: number;
866
- }): ArrayFunction<Item, Item[]>;
867
- declare function createReorder<Item>({ from, to }: {
868
- from: {
869
- start: number;
870
- itemCount: number;
871
- } | number;
872
- to: number;
873
- }): ArrayFunction<Item, Item[]>;
874
- declare function createSwap<Item>({ indices }: {
875
- indices: [number, number];
876
- }): ArrayFunction<Item, Item[]>;
877
- declare function createReplace<Item>({ index, item }: {
878
- index: number;
879
- item: Item;
880
- }): ArrayFunction<Item, Item[]>;
855
+ declare function createDelete<Item>(index: number): ArrayFunction<Item, Item[]>;
856
+ declare function createInsert<Item>(item: Item, index: number): ArrayFunction<Item, Item[]>;
857
+ declare function createReorder<Item>(from: {
858
+ start: number;
859
+ itemCount: number;
860
+ } | number, to: number): ArrayFunction<Item, Item[]>;
861
+ declare function createSwap<Item>(indices: [number, number]): ArrayFunction<Item, Item[]>;
862
+ declare function createReplace<Item>(index: number, item: Item): ArrayFunction<Item, Item[]>;
881
863
  declare function createUnique<Item>(): ArrayFunction<Item, Item[]>;
882
- declare function createSlice<Item>({ from, to }: {
883
- from: number;
884
- to?: number;
885
- }): ArrayFunction<Item, Item[]>;
864
+ declare function createSlice<Item>(from: number, to?: number): ArrayFunction<Item, Item[]>;
886
865
  declare function createFilter<Item>(condition: (item?: Item, index?: number) => boolean): ArrayFunction<Item, Item[]>;
887
866
  declare function createMap<Item, Transformed = Item>(transform: (item?: Item, index?: number) => Transformed): ArrayFunction<Item, Transformed[]>;
888
867
  declare function createConcat<Item>(...arrays: Item[][]): ArrayFunction<Item, Item[]>;
@@ -892,20 +871,14 @@ declare type StringFunction<Returned> = (string: string) => Returned;
892
871
  declare function createSlug(options?: Options): StringFunction<string>;
893
872
  declare function createClip(required: string | RegExp): StringFunction<string>;
894
873
  declare type NumberFunction<Returned> = (number: number) => Returned;
895
- declare function createClamp({ min, max }: {
896
- min: number;
897
- max: number;
898
- }): NumberFunction<number>;
874
+ declare function createClamp(min: number, max: number): NumberFunction<number>;
899
875
  declare type Potentiality<Outcome> = {
900
876
  outcome: Outcome;
901
877
  probability: number;
902
878
  };
903
879
  declare function createDetermine<Outcome>(potentialities: Potentiality<Outcome>[]): NumberFunction<Outcome>;
904
880
  declare type MapFunction<Key, Value, Returned> = (transform: Map<Key, Value>) => Returned;
905
- declare function createRename<Key, Value>({ from, to }: {
906
- from: Key;
907
- to: Key;
908
- }): MapFunction<Key, Value, Map<Key, Value>>;
881
+ declare function createRename<Key, Value>(from: Key, to: Key): MapFunction<Key, Value, Map<Key, Value>>;
909
882
  declare type ObjectFunction<Key extends string | number | symbol, Value, Returned> = (transform: Record<Key, Value>) => Returned;
910
883
  declare function createToEntries<Key extends string | number | symbol, Value>(): ObjectFunction<Key, Value, [Key, Value][]>;
911
884
  declare class Pipeable {
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { reduce, pipe, filter, toArray, findIndex, slice, concat, unique, map, find, some, join, every } from 'lazy-collections';
1
+ import { reduce, pipe, filter, toArray, slice, concat, unique, map, find, findIndex, some, join, 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';
@@ -39,34 +39,30 @@ function createFilterAsync(condition) {
39
39
  return createFilter((_, index) => transformedAsync[index])(array);
40
40
  };
41
41
  }
42
- function createDelete(required) {
42
+ function createDelete(index) {
43
43
  return (array) => {
44
- const deleteIndex = "index" in required ? required.index : findIndex((element) => element === required?.item)(array);
45
- return createConcat(createSlice({ from: 0, to: deleteIndex })(array), createSlice({ from: deleteIndex + 1 })(array))([]);
44
+ return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
46
45
  };
47
46
  }
48
- function createInsert(required) {
47
+ function createInsert(item, index) {
49
48
  return (array) => {
50
- const itemsToInsert = "items" in required ? required.items : [required.item], withItems = createConcat(array, itemsToInsert)([]);
51
- return createReorder({
52
- from: { start: array.length, itemCount: itemsToInsert.length },
53
- to: required.index
54
- })(withItems);
49
+ const withItems = createConcat(array, [item])([]);
50
+ return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
55
51
  };
56
52
  }
57
- function createReorder({ from, to }) {
53
+ function createReorder(from, to) {
58
54
  return (array) => {
59
55
  const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
60
56
  if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
61
57
  return array;
62
58
  }
63
- const itemsToMove = createSlice({ from: itemsToMoveStartIndex, to: itemsToMoveStartIndex + itemsToMoveCount })(array);
59
+ const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
64
60
  if (itemsToMoveStartIndex < insertIndex) {
65
- const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice({ from: 0, to: itemsToMoveStartIndex })(array), betweenItemsToMoveAndInsertIndex = createSlice({ from: itemsToMoveStartIndex + itemsToMoveCount, to: insertIndex + 1 })(array), afterInsertIndex = createSlice({ from: insertIndex + 1 })(array);
61
+ const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
66
62
  return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
67
63
  }
68
64
  if (itemsToMoveStartIndex > insertIndex) {
69
- const beforeInsertion = insertIndex === 0 ? [] : createSlice({ from: 0, to: insertIndex })(array), betweenInsertionAndItemsToMove = createSlice({ from: insertIndex, to: itemsToMoveStartIndex })(array), afterItemsToMove = createSlice({ from: itemsToMoveStartIndex + itemsToMoveCount })(array);
65
+ const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
70
66
  return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
71
67
  }
72
68
  return array;
@@ -75,19 +71,19 @@ function createReorder({ from, to }) {
75
71
  function isObject(value) {
76
72
  return typeof value === "object";
77
73
  }
78
- function createSwap({ indices }) {
74
+ function createSwap(indices) {
79
75
  return (array) => {
80
76
  const { 0: from, 1: to } = indices, { reorderFrom, reorderTo } = (() => {
81
77
  if (from < to) {
82
78
  return {
83
- reorderFrom: createReorder({ from, to }),
84
- reorderTo: createReorder({ from: to - 1, to: from })
79
+ reorderFrom: createReorder(from, to),
80
+ reorderTo: createReorder(to - 1, from)
85
81
  };
86
82
  }
87
83
  if (from > to) {
88
84
  return {
89
- reorderFrom: createReorder({ from, to }),
90
- reorderTo: createReorder({ from: to + 1, to: from })
85
+ reorderFrom: createReorder(from, to),
86
+ reorderTo: createReorder(to + 1, from)
91
87
  };
92
88
  }
93
89
  return {
@@ -98,15 +94,15 @@ function createSwap({ indices }) {
98
94
  return new Pipeable(array).pipe(reorderFrom, reorderTo);
99
95
  };
100
96
  }
101
- function createReplace({ index, item }) {
97
+ function createReplace(index, item) {
102
98
  return (array) => {
103
- return createConcat(createSlice({ from: 0, to: index })(array), [item], createSlice({ from: index + 1 })(array))([]);
99
+ return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
104
100
  };
105
101
  }
106
102
  function createUnique() {
107
103
  return (array) => pipe(unique(), toArray())(array);
108
104
  }
109
- function createSlice({ from, to }) {
105
+ function createSlice(from, to) {
110
106
  return (array) => {
111
107
  return from === to ? [] : pipe(slice(from, to - 1), toArray())(array);
112
108
  };
@@ -131,7 +127,7 @@ function createReverse() {
131
127
  }
132
128
  function createSort(compare) {
133
129
  return (array) => {
134
- return new Pipeable(array).pipe(createSlice({ from: 0 }), (sliced) => sliced.sort(compare));
130
+ return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
135
131
  };
136
132
  }
137
133
  function createSlug(options) {
@@ -144,7 +140,7 @@ function createClip(required) {
144
140
  return string.replace(required, "");
145
141
  };
146
142
  }
147
- function createClamp({ min, max }) {
143
+ function createClamp(min, max) {
148
144
  return (number) => {
149
145
  const maxed = Math.max(number, min);
150
146
  return Math.min(maxed, max);
@@ -160,9 +156,9 @@ function createDetermine(potentialities) {
160
156
  })(potentialities);
161
157
  return (determinant) => find(({ predicate }) => predicate(determinant))(predicates).outcome;
162
158
  }
163
- function createRename({ from, to }) {
159
+ function createRename(from, to) {
164
160
  return (map2) => {
165
- const keys = [...map2.keys()], keyToRenameIndex = findIndex((k) => k === from)(keys), newKeys = createReplace({ index: keyToRenameIndex, item: to })(keys), values = [...map2.values()];
161
+ const keys = [...map2.keys()], keyToRenameIndex = findIndex((k) => k === from)(keys), newKeys = createReplace(keyToRenameIndex, to)(keys), values = [...map2.values()];
166
162
  return createReduce((renamed, key, index) => renamed.set(key, values[index]), /* @__PURE__ */ new Map())(newKeys);
167
163
  };
168
164
  }
@@ -191,7 +187,7 @@ function toEvent(eventType, options) {
191
187
  const implementation = toImplementation(eventType);
192
188
  switch (implementation) {
193
189
  case "keycombo": {
194
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
190
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
195
191
  return new KeyboardEvent("keyDirection" in options ? `key${options.keyDirection}` : "keydown", {
196
192
  ...options.init || {},
197
193
  key: toKey(name),
@@ -203,7 +199,7 @@ function toEvent(eventType, options) {
203
199
  }
204
200
  case "leftclickcombo":
205
201
  case "rightclickcombo": {
206
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
202
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
207
203
  return new MouseEvent(name === "rightclick" ? "contextmenu" : name, {
208
204
  ...options.init || {},
209
205
  ...createReduce((flags, alias) => {
@@ -213,7 +209,7 @@ function toEvent(eventType, options) {
213
209
  });
214
210
  }
215
211
  case "pointercombo": {
216
- const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
212
+ const combo = toCombo(eventType), modifiers = createSlice(0, combo.length - 1)(combo), { 0: name } = createSlice(combo.length - 1)(combo);
217
213
  return new PointerEvent(name === "rightclick" ? "contextmenu" : name, {
218
214
  ...options.init || {},
219
215
  ...createReduce((flags, alias) => {
@@ -646,7 +642,7 @@ class Recognizeable {
646
642
  }
647
643
  recognize(sequenceItem, { onRecognized } = {}) {
648
644
  this.recognizing();
649
- const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice({ from: excess })(this.sequence), [sequenceItem])([]);
645
+ 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])([]);
650
646
  this.effectApi.sequenceItem = sequenceItem;
651
647
  this.effectApi.getSequence = () => newSequence;
652
648
  this.effectApi.onRecognized = onRecognized || (() => {
@@ -1851,7 +1847,7 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1851
1847
  }
1852
1848
  if (isArray(previous) && isArray(next)) {
1853
1849
  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;
1854
- return createSlice({ from: 0, to: sliceEnd })(sliceTarget);
1850
+ return createSlice(0, sliceEnd)(sliceTarget);
1855
1851
  }
1856
1852
  }
1857
1853
  const linear = [
@@ -3057,9 +3053,9 @@ class Pickable {
3057
3053
  return possibleWithoutDuplicates;
3058
3054
  }
3059
3055
  if (possibleWithoutDuplicates.length > this.picks.length) {
3060
- return createSlice({ from: possibleWithoutDuplicates.length - this.picks.length })(possibleWithoutDuplicates);
3056
+ return createSlice(possibleWithoutDuplicates.length - this.picks.length)(possibleWithoutDuplicates);
3061
3057
  }
3062
- return new Pipeable(this.picks).pipe(createSlice({ from: possibleWithoutDuplicates.length }), createConcat(possibleWithoutDuplicates));
3058
+ return new Pipeable(this.picks).pipe(createSlice(possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
3063
3059
  case "lifo":
3064
3060
  if (possibleWithoutDuplicates.length === 0) {
3065
3061
  return this.picks;
@@ -3068,9 +3064,9 @@ class Pickable {
3068
3064
  return possibleWithoutDuplicates;
3069
3065
  }
3070
3066
  if (possibleWithoutDuplicates.length > this.picks.length) {
3071
- return createSlice({ from: 0, to: possibleWithoutDuplicates.length - this.picks.length + 1 })(possibleWithoutDuplicates);
3067
+ return createSlice(0, possibleWithoutDuplicates.length - this.picks.length + 1)(possibleWithoutDuplicates);
3072
3068
  }
3073
- return new Pipeable(this.picks).pipe(createSlice({ from: 0, to: this.picks.length - possibleWithoutDuplicates.length }), createConcat(possibleWithoutDuplicates));
3069
+ return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
3074
3070
  }
3075
3071
  });
3076
3072
  this.computedFirst = Math.min(...this.picks);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.20.34",
3
+ "version": "0.21.0",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",