@bitbybit-dev/base 1.2.0-rc.2 → 1.3.0-rc.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/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +13 -12
- package/lib/api/inputs/color-inputs.d.ts +97 -48
- package/lib/api/inputs/color-inputs.js +95 -46
- package/lib/api/inputs/dates-inputs.d.ts +67 -26
- package/lib/api/inputs/dates-inputs.js +57 -16
- package/lib/api/inputs/io-inputs.d.ts +13 -15
- package/lib/api/inputs/io-inputs.js +7 -8
- package/lib/api/inputs/line-inputs.d.ts +88 -33
- package/lib/api/inputs/line-inputs.js +61 -11
- package/lib/api/inputs/lists-inputs.d.ts +207 -96
- package/lib/api/inputs/lists-inputs.js +153 -45
- package/lib/api/inputs/logic-inputs.d.ts +52 -22
- package/lib/api/inputs/logic-inputs.js +41 -12
- package/lib/api/inputs/math-inputs.d.ts +113 -52
- package/lib/api/inputs/math-inputs.js +112 -51
- package/lib/api/inputs/mesh-inputs.d.ts +30 -11
- package/lib/api/inputs/mesh-inputs.js +21 -3
- package/lib/api/inputs/point-inputs.d.ts +240 -107
- package/lib/api/inputs/point-inputs.js +199 -73
- package/lib/api/inputs/polyline-inputs.d.ts +68 -28
- package/lib/api/inputs/polyline-inputs.js +48 -13
- package/lib/api/inputs/text-inputs.d.ts +117 -46
- package/lib/api/inputs/text-inputs.js +111 -41
- package/lib/api/inputs/transforms-inputs.d.ts +65 -23
- package/lib/api/inputs/transforms-inputs.js +64 -22
- package/lib/api/inputs/vector-inputs.d.ts +154 -76
- package/lib/api/inputs/vector-inputs.js +132 -57
- package/lib/api/models/point/hex-grid-data.d.ts +1 -1
- package/lib/api/models/point/hex-grid-data.js +1 -1
- package/lib/api/services/color.d.ts +149 -70
- package/lib/api/services/color.js +149 -70
- package/lib/api/services/dates.d.ts +313 -150
- package/lib/api/services/dates.js +313 -150
- package/lib/api/services/line.d.ts +138 -68
- package/lib/api/services/line.js +138 -68
- package/lib/api/services/lists.d.ts +357 -177
- package/lib/api/services/lists.js +357 -177
- package/lib/api/services/logic.d.ts +98 -45
- package/lib/api/services/logic.js +98 -45
- package/lib/api/services/math.d.ts +363 -211
- package/lib/api/services/math.js +363 -211
- package/lib/api/services/mesh.d.ts +73 -31
- package/lib/api/services/mesh.js +73 -31
- package/lib/api/services/point.d.ts +367 -147
- package/lib/api/services/point.js +367 -147
- package/lib/api/services/polyline.d.ts +146 -71
- package/lib/api/services/polyline.js +146 -71
- package/lib/api/services/text.d.ts +320 -165
- package/lib/api/services/text.js +320 -165
- package/lib/api/services/transforms.d.ts +145 -58
- package/lib/api/services/transforms.js +145 -58
- package/lib/api/services/vector.d.ts +381 -156
- package/lib/api/services/vector.js +381 -156
- package/package.json +1 -1
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import * as Inputs from "../inputs";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Reading, building and reshaping plain arrays of any kind of item. Positions are 0-based: index 0
|
|
4
|
+
* is the first item. Most methods take a `clone` option, on by default, that deep-copies the list
|
|
5
|
+
* first so the input is never changed; switched off, the modifying methods work on the list in
|
|
6
|
+
* place, which is faster for large data. `removeAllItems` always empties the list it is given.
|
|
7
7
|
*/
|
|
8
8
|
export class Lists {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Reads the item at a position in the list, counting from 0.
|
|
11
|
+
*
|
|
12
|
+
* An index outside the list throws an error.
|
|
13
|
+
* Example: [10, 20, 30, 40] at index 2 -> 30
|
|
14
|
+
* @param inputs - The list, the index and whether to copy the item
|
|
15
|
+
* @returns The item at that index
|
|
14
16
|
* @group get
|
|
15
17
|
* @shortname item by index
|
|
16
18
|
* @drawable false
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const third = bitbybit.lists.getItem({ list: [10, 20, 30, 40], index: 2, clone: true });
|
|
22
|
+
* ```
|
|
17
23
|
*/
|
|
18
24
|
getItem(inputs) {
|
|
19
25
|
if (inputs.index < 0 || inputs.index >= inputs.list.length) {
|
|
@@ -29,10 +35,11 @@ export class Lists {
|
|
|
29
35
|
return result;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
38
|
+
* Reads the first item of the list.
|
|
39
|
+
*
|
|
40
|
+
* Example: [10, 20, 30, 40] -> 10
|
|
41
|
+
* @param inputs - The list and whether to copy the item
|
|
42
|
+
* @returns The first item
|
|
36
43
|
* @group get
|
|
37
44
|
* @shortname first item
|
|
38
45
|
* @drawable false
|
|
@@ -51,10 +58,11 @@ export class Lists {
|
|
|
51
58
|
return result;
|
|
52
59
|
}
|
|
53
60
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
61
|
+
* Reads the last item of the list.
|
|
62
|
+
*
|
|
63
|
+
* Example: [10, 20, 30, 40] -> 40
|
|
64
|
+
* @param inputs - The list and whether to copy the item
|
|
65
|
+
* @returns The last item
|
|
58
66
|
* @group get
|
|
59
67
|
* @shortname last item
|
|
60
68
|
* @drawable false
|
|
@@ -73,13 +81,19 @@ export class Lists {
|
|
|
73
81
|
return result;
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
84
|
+
* Keeps each item of the list with a given probability and drops the rest, so the result
|
|
85
|
+
* differs on every call.
|
|
86
|
+
*
|
|
87
|
+
* Example: [1, 2, 3, 4, 5] with threshold 0.5 -> perhaps [1, 3, 5]
|
|
88
|
+
* @param inputs - The list, the probability of keeping an item from 0 to 1, and whether to copy
|
|
89
|
+
* @returns The items that were kept, in their original order
|
|
80
90
|
* @group get
|
|
81
91
|
* @shortname random get threshold
|
|
82
92
|
* @drawable false
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const some = bitbybit.lists.randomGetThreshold({ list: [1, 2, 3, 4, 5], threshold: 0.5, clone: true });
|
|
96
|
+
* ```
|
|
83
97
|
*/
|
|
84
98
|
randomGetThreshold(inputs) {
|
|
85
99
|
let res = inputs.list;
|
|
@@ -95,14 +109,19 @@ export class Lists {
|
|
|
95
109
|
return newList;
|
|
96
110
|
}
|
|
97
111
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
* Cuts out the items from a start index up to, but not including, an end index.
|
|
113
|
+
*
|
|
114
|
+
* Example: [10, 20, 30, 40, 50] from 1 to 4 -> [20, 30, 40]
|
|
115
|
+
* @param inputs - The list, the start and end indexes, and whether to copy
|
|
116
|
+
* @returns The items in that range
|
|
117
|
+
* @group get
|
|
118
|
+
* @shortname sublist
|
|
119
|
+
* @drawable false
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const middle = bitbybit.lists.getSubList({ list: [10, 20, 30, 40, 50], indexStart: 1, indexEnd: 4, clone: true });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
106
125
|
getSubList(inputs) {
|
|
107
126
|
let result;
|
|
108
127
|
if (inputs.clone) {
|
|
@@ -114,14 +133,19 @@ export class Lists {
|
|
|
114
133
|
return result;
|
|
115
134
|
}
|
|
116
135
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* Example:
|
|
120
|
-
*
|
|
121
|
-
* @
|
|
136
|
+
* Keeps every nth item, starting from an offset.
|
|
137
|
+
*
|
|
138
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth 3 and offset 0 -> [0, 3, 6]; with nth 2 and
|
|
139
|
+
* offset 1 -> [1, 3, 5, 7]
|
|
140
|
+
* @param inputs - The list, the step, the offset to start from, and whether to copy
|
|
141
|
+
* @returns Every nth item, in order
|
|
122
142
|
* @group get
|
|
123
143
|
* @shortname every n-th
|
|
124
144
|
* @drawable false
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const everyThird = bitbybit.lists.getNthItem({ list: [0, 1, 2, 3, 4, 5, 6, 7, 8], nth: 3, offset: 0, clone: true });
|
|
148
|
+
* ```
|
|
125
149
|
*/
|
|
126
150
|
getNthItem(inputs) {
|
|
127
151
|
let cloned = inputs.list;
|
|
@@ -137,13 +161,19 @@ export class Lists {
|
|
|
137
161
|
return result;
|
|
138
162
|
}
|
|
139
163
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
164
|
+
* Keeps the items where a repeating true/false pattern says true and drops the others.
|
|
165
|
+
*
|
|
166
|
+
* The pattern starts over when it runs out.
|
|
167
|
+
* Example: [0, 1, 2, 3, 4, 5] with pattern [true, true, false] -> [0, 1, 3, 4]
|
|
168
|
+
* @param inputs - The list and the pattern
|
|
169
|
+
* @returns The items the pattern kept, in order
|
|
144
170
|
* @group get
|
|
145
171
|
* @shortname by pattern
|
|
146
172
|
* @drawable false
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const kept = bitbybit.lists.getByPattern({ list: [0, 1, 2, 3, 4, 5], pattern: [true, true, false] });
|
|
176
|
+
* ```
|
|
147
177
|
*/
|
|
148
178
|
getByPattern(inputs) {
|
|
149
179
|
const { list, pattern } = inputs;
|
|
@@ -175,13 +205,21 @@ export class Lists {
|
|
|
175
205
|
return result;
|
|
176
206
|
}
|
|
177
207
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
208
|
+
* Regroups nested lists by position: the first items of every list go together, then the second
|
|
209
|
+
* items, and so on.
|
|
210
|
+
*
|
|
211
|
+
* `level` says how many levels of nesting to flatten inside each list first; 0 regroups them as
|
|
212
|
+
* they are.
|
|
213
|
+
* Example: [[0, 1, 2], [3, 4, 5]] at level 0 -> [[0, 3], [1, 4], [2, 5]]
|
|
214
|
+
* @param inputs - The lists and the depth at which to regroup
|
|
215
|
+
* @returns The regrouped lists
|
|
182
216
|
* @group get
|
|
183
217
|
* @shortname merge levels
|
|
184
218
|
* @drawable false
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const columns = bitbybit.lists.mergeElementsOfLists({ lists: [[0, 1, 2], [3, 4, 5]], level: 0 });
|
|
222
|
+
* ```
|
|
185
223
|
*/
|
|
186
224
|
mergeElementsOfLists(inputs) {
|
|
187
225
|
const lists = inputs.lists;
|
|
@@ -225,13 +263,18 @@ export class Lists {
|
|
|
225
263
|
return final;
|
|
226
264
|
}
|
|
227
265
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* @
|
|
266
|
+
* Measures the longest list among several.
|
|
267
|
+
*
|
|
268
|
+
* Example: [[1, 2], [3, 4, 5, 6], [7]] -> 4
|
|
269
|
+
* @param inputs - The lists to measure
|
|
270
|
+
* @returns The length of the longest one
|
|
232
271
|
* @group get
|
|
233
272
|
* @shortname longest list length
|
|
234
273
|
* @drawable false
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const longest = bitbybit.lists.getLongestListLength({ lists: [[1, 2], [3, 4, 5, 6], [7]] });
|
|
277
|
+
* ```
|
|
235
278
|
*/
|
|
236
279
|
getLongestListLength(inputs) {
|
|
237
280
|
let longestSoFar = 0;
|
|
@@ -245,10 +288,11 @@ export class Lists {
|
|
|
245
288
|
return longestSoFar;
|
|
246
289
|
}
|
|
247
290
|
/**
|
|
248
|
-
* Reverses the order of
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* @
|
|
291
|
+
* Reverses the order of the items.
|
|
292
|
+
*
|
|
293
|
+
* Example: [1, 2, 3, 4, 5] -> [5, 4, 3, 2, 1]
|
|
294
|
+
* @param inputs - The list and whether to copy it first
|
|
295
|
+
* @returns The reversed list
|
|
252
296
|
* @group edit
|
|
253
297
|
* @shortname reverse
|
|
254
298
|
* @drawable false
|
|
@@ -261,10 +305,11 @@ export class Lists {
|
|
|
261
305
|
return res.reverse();
|
|
262
306
|
}
|
|
263
307
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* @
|
|
308
|
+
* Puts the items in a random order, different on every call.
|
|
309
|
+
*
|
|
310
|
+
* Example: [1, 2, 3, 4, 5] -> perhaps [3, 1, 5, 2, 4]
|
|
311
|
+
* @param inputs - The list and whether to copy it first
|
|
312
|
+
* @returns The shuffled list
|
|
268
313
|
* @group edit
|
|
269
314
|
* @shortname shuffle
|
|
270
315
|
* @drawable false
|
|
@@ -281,13 +326,19 @@ export class Lists {
|
|
|
281
326
|
return res;
|
|
282
327
|
}
|
|
283
328
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
329
|
+
* Turns a list of lists on its side: rows become columns and columns become rows.
|
|
330
|
+
*
|
|
331
|
+
* All the inner lists must have the same length.
|
|
332
|
+
* Example: [[0, 1, 2], [3, 4, 5]] -> [[0, 3], [1, 4], [2, 5]]
|
|
333
|
+
* @param inputs - The list of lists and whether to copy it first
|
|
334
|
+
* @returns The transposed list of lists
|
|
288
335
|
* @group edit
|
|
289
336
|
* @shortname flip lists
|
|
290
337
|
* @drawable false
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const columns = bitbybit.lists.flipLists({ list: [[0, 1, 2], [3, 4, 5]], clone: true });
|
|
341
|
+
* ```
|
|
291
342
|
*/
|
|
292
343
|
flipLists(inputs) {
|
|
293
344
|
if (inputs.list.length > 0) {
|
|
@@ -318,14 +369,20 @@ export class Lists {
|
|
|
318
369
|
}
|
|
319
370
|
}
|
|
320
371
|
/**
|
|
321
|
-
* Splits the list into
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
372
|
+
* Splits the list into groups of n items.
|
|
373
|
+
*
|
|
374
|
+
* Items left over at the end are dropped unless `keepRemainder` is on, which adds them as a
|
|
375
|
+
* shorter last group.
|
|
376
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] in groups of 3 -> [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
|
|
377
|
+
* @param inputs - The list, the group size and whether to keep a partial last group
|
|
378
|
+
* @returns The groups, in order
|
|
326
379
|
* @group edit
|
|
327
380
|
* @shortname group elements
|
|
328
381
|
* @drawable false
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const pairs = bitbybit.lists.groupNth({ list: [0, 1, 2, 3, 4], nrElements: 2, keepRemainder: true });
|
|
385
|
+
* ```
|
|
329
386
|
*/
|
|
330
387
|
groupNth(inputs) {
|
|
331
388
|
const groupElements = (inputs) => {
|
|
@@ -348,34 +405,47 @@ export class Lists {
|
|
|
348
405
|
return groupElements(inputs);
|
|
349
406
|
}
|
|
350
407
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
408
|
+
* Tells whether an item is in the list.
|
|
409
|
+
*
|
|
410
|
+
* Items are compared by identity, so an object is found only if the very same object is in the
|
|
411
|
+
* list.
|
|
412
|
+
* Example: [10, 20, 30, 40] includes 30 -> true, includes 50 -> false
|
|
413
|
+
* @param inputs - The list and the item to look for
|
|
414
|
+
* @returns True when the item is in the list
|
|
355
415
|
* @group get
|
|
356
416
|
* @shortname contains item
|
|
357
417
|
* @drawable false
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* const found = bitbybit.lists.includes({ list: [10, 20, 30, 40], item: 30 });
|
|
421
|
+
* ```
|
|
358
422
|
*/
|
|
359
423
|
includes(inputs) {
|
|
360
424
|
return inputs.list.includes(inputs.item);
|
|
361
425
|
}
|
|
362
426
|
/**
|
|
363
|
-
* Finds the position
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* @
|
|
427
|
+
* Finds the position of the first occurrence of an item, or -1 when it is not in the list.
|
|
428
|
+
*
|
|
429
|
+
* Example: [10, 20, 30, 20, 40] finding 20 -> 1, finding 50 -> -1
|
|
430
|
+
* @param inputs - The list and the item to look for
|
|
431
|
+
* @returns The 0-based index, or -1
|
|
367
432
|
* @group get
|
|
368
433
|
* @shortname find index
|
|
369
434
|
* @drawable false
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* const where = bitbybit.lists.findIndex({ list: [10, 20, 30, 20, 40], item: 20 });
|
|
438
|
+
* ```
|
|
370
439
|
*/
|
|
371
440
|
findIndex(inputs) {
|
|
372
441
|
return inputs.list.indexOf(inputs.item);
|
|
373
442
|
}
|
|
374
443
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* @
|
|
444
|
+
* Measures how deeply lists are nested inside the list.
|
|
445
|
+
*
|
|
446
|
+
* Example: [1, 2, 3] -> 1, [[1, 2], [3, 4]] -> 2, [[[1]]] -> 3
|
|
447
|
+
* @param inputs - The list
|
|
448
|
+
* @returns The number of nesting levels
|
|
379
449
|
* @group get
|
|
380
450
|
* @shortname max list depth
|
|
381
451
|
* @drawable false
|
|
@@ -403,10 +473,11 @@ export class Lists {
|
|
|
403
473
|
return levels;
|
|
404
474
|
}
|
|
405
475
|
/**
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* @
|
|
476
|
+
* Counts the items in the list.
|
|
477
|
+
*
|
|
478
|
+
* Example: [10, 20, 30, 40, 50] -> 5, [] -> 0
|
|
479
|
+
* @param inputs - The list
|
|
480
|
+
* @returns The number of items
|
|
410
481
|
* @group get
|
|
411
482
|
* @shortname list length
|
|
412
483
|
* @drawable false
|
|
@@ -415,13 +486,18 @@ export class Lists {
|
|
|
415
486
|
return inputs.list.length;
|
|
416
487
|
}
|
|
417
488
|
/**
|
|
418
|
-
* Inserts an item at a
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* @
|
|
489
|
+
* Inserts an item at a position; the items from that position on shift up by one.
|
|
490
|
+
*
|
|
491
|
+
* Example: [10, 20, 30, 40] with 99 at index 2 -> [10, 20, 99, 30, 40]
|
|
492
|
+
* @param inputs - The list, the item, the index and whether to copy
|
|
493
|
+
* @returns The list with the item inserted
|
|
422
494
|
* @group add
|
|
423
495
|
* @shortname add item
|
|
424
496
|
* @drawable false
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const longer = bitbybit.lists.addItemAtIndex({ list: [10, 20, 30, 40], item: 99, index: 2, clone: true });
|
|
500
|
+
* ```
|
|
425
501
|
*/
|
|
426
502
|
addItemAtIndex(inputs) {
|
|
427
503
|
let res = inputs.list;
|
|
@@ -434,13 +510,18 @@ export class Lists {
|
|
|
434
510
|
return res;
|
|
435
511
|
}
|
|
436
512
|
/**
|
|
437
|
-
* Inserts the same item at
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
* @
|
|
513
|
+
* Inserts the same item at several positions of the original list.
|
|
514
|
+
*
|
|
515
|
+
* Example: [10, 20, 30] with 99 at indexes [0, 2] -> [99, 10, 20, 99, 30]
|
|
516
|
+
* @param inputs - The list, the item, the indexes and whether to copy
|
|
517
|
+
* @returns The list with the item inserted at each index
|
|
441
518
|
* @group add
|
|
442
519
|
* @shortname add item at indexes
|
|
443
520
|
* @drawable false
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* const marked = bitbybit.lists.addItemAtIndexes({ list: [10, 20, 30], item: 99, indexes: [0, 2], clone: true });
|
|
524
|
+
* ```
|
|
444
525
|
*/
|
|
445
526
|
addItemAtIndexes(inputs) {
|
|
446
527
|
let cloned = inputs.list;
|
|
@@ -458,13 +539,20 @@ export class Lists {
|
|
|
458
539
|
return cloned;
|
|
459
540
|
}
|
|
460
541
|
/**
|
|
461
|
-
* Inserts
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
542
|
+
* Inserts several items, the first at the first index, the second at the second, and so on, all
|
|
543
|
+
* counted on the original list.
|
|
544
|
+
*
|
|
545
|
+
* The indexes must be in ascending order and there must be one per item, or an error is thrown.
|
|
546
|
+
* Example: [10, 20, 30] with items [88, 99] at indexes [1, 2] -> [10, 88, 20, 99, 30]
|
|
547
|
+
* @param inputs - The list, the items, one index per item and whether to copy
|
|
548
|
+
* @returns The list with the items inserted
|
|
465
549
|
* @group add
|
|
466
550
|
* @shortname add items
|
|
467
551
|
* @drawable false
|
|
552
|
+
* @example
|
|
553
|
+
* ```typescript
|
|
554
|
+
* const merged = bitbybit.lists.addItemsAtIndexes({ list: [10, 20, 30], items: [88, 99], indexes: [1, 2], clone: true });
|
|
555
|
+
* ```
|
|
468
556
|
*/
|
|
469
557
|
addItemsAtIndexes(inputs) {
|
|
470
558
|
if (inputs.items.length !== inputs.indexes.length) {
|
|
@@ -491,13 +579,18 @@ export class Lists {
|
|
|
491
579
|
return cloned;
|
|
492
580
|
}
|
|
493
581
|
/**
|
|
494
|
-
* Removes the item at a
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* @
|
|
582
|
+
* Removes the item at a position.
|
|
583
|
+
*
|
|
584
|
+
* Example: [10, 20, 30, 40, 50] removing index 2 -> [10, 20, 40, 50]
|
|
585
|
+
* @param inputs - The list, the index and whether to copy
|
|
586
|
+
* @returns The list without that item
|
|
498
587
|
* @group remove
|
|
499
588
|
* @shortname remove item
|
|
500
589
|
* @drawable false
|
|
590
|
+
* @example
|
|
591
|
+
* ```typescript
|
|
592
|
+
* const shorter = bitbybit.lists.removeItemAtIndex({ list: [10, 20, 30, 40, 50], index: 2, clone: true });
|
|
593
|
+
* ```
|
|
501
594
|
*/
|
|
502
595
|
removeItemAtIndex(inputs) {
|
|
503
596
|
let res = inputs.list;
|
|
@@ -510,10 +603,11 @@ export class Lists {
|
|
|
510
603
|
return res;
|
|
511
604
|
}
|
|
512
605
|
/**
|
|
513
|
-
* Removes the first item
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* @
|
|
606
|
+
* Removes the first item.
|
|
607
|
+
*
|
|
608
|
+
* Example: [10, 20, 30, 40] -> [20, 30, 40]
|
|
609
|
+
* @param inputs - The list and whether to copy it first
|
|
610
|
+
* @returns The list without its first item
|
|
517
611
|
* @group remove
|
|
518
612
|
* @shortname remove first item
|
|
519
613
|
* @drawable false
|
|
@@ -529,10 +623,11 @@ export class Lists {
|
|
|
529
623
|
return res;
|
|
530
624
|
}
|
|
531
625
|
/**
|
|
532
|
-
* Removes the last item
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* @
|
|
626
|
+
* Removes the last item.
|
|
627
|
+
*
|
|
628
|
+
* Example: [10, 20, 30, 40] -> [10, 20, 30]
|
|
629
|
+
* @param inputs - The list and whether to copy it first
|
|
630
|
+
* @returns The list without its last item
|
|
536
631
|
* @group remove
|
|
537
632
|
* @shortname remove last item
|
|
538
633
|
* @drawable false
|
|
@@ -548,13 +643,18 @@ export class Lists {
|
|
|
548
643
|
return res;
|
|
549
644
|
}
|
|
550
645
|
/**
|
|
551
|
-
* Removes an item
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
* @
|
|
646
|
+
* Removes an item counted from the end: index 0 is the last item, 1 the one before it.
|
|
647
|
+
*
|
|
648
|
+
* Example: [10, 20, 30, 40, 50] removing index 1 from the end -> [10, 20, 30, 50]
|
|
649
|
+
* @param inputs - The list, the index from the end and whether to copy
|
|
650
|
+
* @returns The list without that item
|
|
555
651
|
* @group remove
|
|
556
652
|
* @shortname remove item from end
|
|
557
653
|
* @drawable false
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* const shorter = bitbybit.lists.removeItemAtIndexFromEnd({ list: [10, 20, 30, 40, 50], index: 1, clone: true });
|
|
657
|
+
* ```
|
|
558
658
|
*/
|
|
559
659
|
removeItemAtIndexFromEnd(inputs) {
|
|
560
660
|
let res = inputs.list;
|
|
@@ -568,13 +668,18 @@ export class Lists {
|
|
|
568
668
|
return res;
|
|
569
669
|
}
|
|
570
670
|
/**
|
|
571
|
-
* Removes items at
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
* @
|
|
671
|
+
* Removes the items at several positions, all counted on the original list.
|
|
672
|
+
*
|
|
673
|
+
* Example: [10, 20, 30, 40, 50] removing indexes [1, 3] -> [10, 30, 50]
|
|
674
|
+
* @param inputs - The list, the indexes and whether to copy
|
|
675
|
+
* @returns The list without those items
|
|
575
676
|
* @group remove
|
|
576
677
|
* @shortname remove items
|
|
577
678
|
* @drawable false
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* const kept = bitbybit.lists.removeItemsAtIndexes({ list: [10, 20, 30, 40, 50], indexes: [1, 3], clone: true });
|
|
682
|
+
* ```
|
|
578
683
|
*/
|
|
579
684
|
removeItemsAtIndexes(inputs) {
|
|
580
685
|
let res = inputs.list;
|
|
@@ -591,10 +696,11 @@ export class Lists {
|
|
|
591
696
|
return res;
|
|
592
697
|
}
|
|
593
698
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
* @
|
|
699
|
+
* Empties the list it is given, in place: the same array comes back with no items in it.
|
|
700
|
+
*
|
|
701
|
+
* Example: [10, 20, 30, 40] -> []
|
|
702
|
+
* @param inputs - The list to empty
|
|
703
|
+
* @returns The same list, now empty
|
|
598
704
|
* @group remove
|
|
599
705
|
* @shortname remove all items
|
|
600
706
|
* @drawable false
|
|
@@ -604,13 +710,18 @@ export class Lists {
|
|
|
604
710
|
return inputs.list;
|
|
605
711
|
}
|
|
606
712
|
/**
|
|
607
|
-
* Removes every nth item
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
* @
|
|
713
|
+
* Removes every nth item, starting from an offset.
|
|
714
|
+
*
|
|
715
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth 3 and offset 0 -> [1, 2, 4, 5, 7, 8]
|
|
716
|
+
* @param inputs - The list, the step, the offset to start from and whether to copy
|
|
717
|
+
* @returns The list without every nth item
|
|
611
718
|
* @group remove
|
|
612
719
|
* @shortname every n-th
|
|
613
720
|
* @drawable false
|
|
721
|
+
* @example
|
|
722
|
+
* ```typescript
|
|
723
|
+
* const thinned = bitbybit.lists.removeNthItem({ list: [0, 1, 2, 3, 4, 5, 6, 7, 8], nth: 3, offset: 0, clone: true });
|
|
724
|
+
* ```
|
|
614
725
|
*/
|
|
615
726
|
removeNthItem(inputs) {
|
|
616
727
|
let res = inputs.list;
|
|
@@ -626,13 +737,19 @@ export class Lists {
|
|
|
626
737
|
return result;
|
|
627
738
|
}
|
|
628
739
|
/**
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
740
|
+
* Drops each item of the list with a given probability and keeps the rest, so the result
|
|
741
|
+
* differs on every call.
|
|
742
|
+
*
|
|
743
|
+
* Example: [1, 2, 3, 4, 5] with threshold 0.5 -> perhaps [2, 4]
|
|
744
|
+
* @param inputs - The list, the probability of dropping an item from 0 to 1, and whether to copy
|
|
745
|
+
* @returns The items that survived, in their original order
|
|
633
746
|
* @group remove
|
|
634
747
|
* @shortname random remove threshold
|
|
635
748
|
* @drawable false
|
|
749
|
+
* @example
|
|
750
|
+
* ```typescript
|
|
751
|
+
* const some = bitbybit.lists.randomRemoveThreshold({ list: [1, 2, 3, 4, 5], threshold: 0.5, clone: true });
|
|
752
|
+
* ```
|
|
636
753
|
*/
|
|
637
754
|
randomRemoveThreshold(inputs) {
|
|
638
755
|
let res = inputs.list;
|
|
@@ -648,10 +765,11 @@ export class Lists {
|
|
|
648
765
|
return newList;
|
|
649
766
|
}
|
|
650
767
|
/**
|
|
651
|
-
* Removes
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* @
|
|
768
|
+
* Removes repeated numbers, keeping the first occurrence of each.
|
|
769
|
+
*
|
|
770
|
+
* Example: [1, 2, 3, 2, 4, 3, 5] -> [1, 2, 3, 4, 5]
|
|
771
|
+
* @param inputs - The numbers and whether to copy
|
|
772
|
+
* @returns The numbers without repeats, in their original order
|
|
655
773
|
* @group remove
|
|
656
774
|
* @shortname remove duplicate numbers
|
|
657
775
|
* @drawable false
|
|
@@ -664,13 +782,19 @@ export class Lists {
|
|
|
664
782
|
return res.filter((value, index, self) => self.indexOf(value) === index);
|
|
665
783
|
}
|
|
666
784
|
/**
|
|
667
|
-
* Removes
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
785
|
+
* Removes numbers that are within a tolerance of one already kept, so values that differ only
|
|
786
|
+
* by floating-point noise count as the same.
|
|
787
|
+
*
|
|
788
|
+
* Example: [1.0, 1.001, 2.0, 2.002, 3.0] with tolerance 0.01 -> [1.0, 2.0, 3.0]
|
|
789
|
+
* @param inputs - The numbers, the tolerance and whether to copy
|
|
790
|
+
* @returns The numbers without near-repeats, in their original order
|
|
671
791
|
* @group remove
|
|
672
792
|
* @shortname remove duplicates tol
|
|
673
793
|
* @drawable false
|
|
794
|
+
* @example
|
|
795
|
+
* ```typescript
|
|
796
|
+
* const distinct = bitbybit.lists.removeDuplicateNumbersTolerance({ list: [1.0, 1.001, 2.0], tolerance: 0.01, clone: true });
|
|
797
|
+
* ```
|
|
674
798
|
*/
|
|
675
799
|
removeDuplicateNumbersTolerance(inputs) {
|
|
676
800
|
let res = inputs.list;
|
|
@@ -680,10 +804,12 @@ export class Lists {
|
|
|
680
804
|
return res.filter((value, index, self) => self.findIndex(s => Math.abs(s - value) < inputs.tolerance) === index);
|
|
681
805
|
}
|
|
682
806
|
/**
|
|
683
|
-
* Removes
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
807
|
+
* Removes repeated items of any kind, keeping the first occurrence of each.
|
|
808
|
+
*
|
|
809
|
+
* Items are compared by identity, so two equal-looking objects both stay.
|
|
810
|
+
* Example: ['a', 'b', 'c', 'a', 'd', 'b'] -> ['a', 'b', 'c', 'd']
|
|
811
|
+
* @param inputs - The list and whether to copy
|
|
812
|
+
* @returns The list without repeats, in its original order
|
|
687
813
|
* @group remove
|
|
688
814
|
* @shortname remove duplicates
|
|
689
815
|
* @drawable false
|
|
@@ -696,13 +822,18 @@ export class Lists {
|
|
|
696
822
|
return res.filter((value, index, self) => self.indexOf(value) === index);
|
|
697
823
|
}
|
|
698
824
|
/**
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* @
|
|
825
|
+
* Adds an item at the end of the list.
|
|
826
|
+
*
|
|
827
|
+
* Example: [10, 20, 30] adding 40 -> [10, 20, 30, 40]
|
|
828
|
+
* @param inputs - The list, the item and whether to copy
|
|
829
|
+
* @returns The list with the item at its end
|
|
703
830
|
* @group add
|
|
704
831
|
* @shortname add item to list
|
|
705
832
|
* @drawable false
|
|
833
|
+
* @example
|
|
834
|
+
* ```typescript
|
|
835
|
+
* const longer = bitbybit.lists.addItem({ list: [10, 20, 30], item: 40, clone: true });
|
|
836
|
+
* ```
|
|
706
837
|
*/
|
|
707
838
|
addItem(inputs) {
|
|
708
839
|
let res = inputs.list;
|
|
@@ -713,13 +844,18 @@ export class Lists {
|
|
|
713
844
|
return res;
|
|
714
845
|
}
|
|
715
846
|
/**
|
|
716
|
-
* Adds an item
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
* @
|
|
847
|
+
* Adds an item at the start of the list.
|
|
848
|
+
*
|
|
849
|
+
* Example: [10, 20, 30] prepending 5 -> [5, 10, 20, 30]
|
|
850
|
+
* @param inputs - The list, the item and whether to copy
|
|
851
|
+
* @returns The list with the item at its start
|
|
720
852
|
* @group add
|
|
721
853
|
* @shortname prepend item to list
|
|
722
854
|
* @drawable false
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* const longer = bitbybit.lists.prependItem({ list: [10, 20, 30], item: 5, clone: true });
|
|
858
|
+
* ```
|
|
723
859
|
*/
|
|
724
860
|
prependItem(inputs) {
|
|
725
861
|
let res = inputs.list;
|
|
@@ -730,13 +866,18 @@ export class Lists {
|
|
|
730
866
|
return res;
|
|
731
867
|
}
|
|
732
868
|
/**
|
|
733
|
-
* Adds an item
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
* @
|
|
869
|
+
* Adds an item at the start or at the end of the list, as chosen.
|
|
870
|
+
*
|
|
871
|
+
* Example: [10, 20, 30] adding 5 first -> [5, 10, 20, 30]; last -> [10, 20, 30, 5]
|
|
872
|
+
* @param inputs - The list, the item, the position and whether to copy
|
|
873
|
+
* @returns The list with the item added
|
|
737
874
|
* @group add
|
|
738
875
|
* @shortname item at first or last
|
|
739
876
|
* @drawable false
|
|
877
|
+
* @example
|
|
878
|
+
* ```typescript
|
|
879
|
+
* const longer = bitbybit.lists.addItemFirstLast({ list: [10, 20, 30], item: 5, position: Bit.Inputs.Lists.firstLastEnum.first, clone: true });
|
|
880
|
+
* ```
|
|
740
881
|
*/
|
|
741
882
|
addItemFirstLast(inputs) {
|
|
742
883
|
let res = inputs.list;
|
|
@@ -752,13 +893,18 @@ export class Lists {
|
|
|
752
893
|
return res;
|
|
753
894
|
}
|
|
754
895
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* @
|
|
896
|
+
* Joins several lists into one, end to end.
|
|
897
|
+
*
|
|
898
|
+
* Example: [[1, 2], [3, 4], [5, 6]] -> [1, 2, 3, 4, 5, 6]
|
|
899
|
+
* @param inputs - The lists to join and whether to copy
|
|
900
|
+
* @returns One list with all the items
|
|
759
901
|
* @group add
|
|
760
902
|
* @shortname concatenate lists
|
|
761
903
|
* @drawable false
|
|
904
|
+
* @example
|
|
905
|
+
* ```typescript
|
|
906
|
+
* const all = bitbybit.lists.concatenate({ lists: [[1, 2], [3, 4], [5, 6]], clone: true });
|
|
907
|
+
* ```
|
|
762
908
|
*/
|
|
763
909
|
concatenate(inputs) {
|
|
764
910
|
let result = [];
|
|
@@ -775,9 +921,10 @@ export class Lists {
|
|
|
775
921
|
return result;
|
|
776
922
|
}
|
|
777
923
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
924
|
+
* Makes a new list with nothing in it.
|
|
925
|
+
*
|
|
926
|
+
* Example: -> []
|
|
927
|
+
* @returns An empty list
|
|
781
928
|
* @group create
|
|
782
929
|
* @shortname empty list
|
|
783
930
|
* @drawable false
|
|
@@ -786,13 +933,18 @@ export class Lists {
|
|
|
786
933
|
return [];
|
|
787
934
|
}
|
|
788
935
|
/**
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
* @
|
|
936
|
+
* Makes a list that holds the same item a number of times.
|
|
937
|
+
*
|
|
938
|
+
* Example: 5 three times -> [5, 5, 5]
|
|
939
|
+
* @param inputs - The item and how many times to repeat it
|
|
940
|
+
* @returns The list of repeats
|
|
793
941
|
* @group create
|
|
794
942
|
* @shortname repeat
|
|
795
943
|
* @drawable false
|
|
944
|
+
* @example
|
|
945
|
+
* ```typescript
|
|
946
|
+
* const fives = bitbybit.lists.repeat({ item: 5, times: 3 });
|
|
947
|
+
* ```
|
|
796
948
|
*/
|
|
797
949
|
repeat(inputs) {
|
|
798
950
|
const result = [];
|
|
@@ -802,13 +954,18 @@ export class Lists {
|
|
|
802
954
|
return result;
|
|
803
955
|
}
|
|
804
956
|
/**
|
|
805
|
-
* Repeats a pattern of items
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
* @
|
|
957
|
+
* Repeats a pattern of items over and over until the list reaches a given length.
|
|
958
|
+
*
|
|
959
|
+
* Example: [1, 2, 3] to length 7 -> [1, 2, 3, 1, 2, 3, 1]
|
|
960
|
+
* @param inputs - The pattern, the length to reach and whether to copy
|
|
961
|
+
* @returns The repeated pattern, cut to the length
|
|
809
962
|
* @group create
|
|
810
963
|
* @shortname repeat in pattern
|
|
811
964
|
* @drawable false
|
|
965
|
+
* @example
|
|
966
|
+
* ```typescript
|
|
967
|
+
* const cycle = bitbybit.lists.repeatInPattern({ list: [1, 2, 3], lengthLimit: 7, clone: true });
|
|
968
|
+
* ```
|
|
812
969
|
*/
|
|
813
970
|
repeatInPattern(inputs) {
|
|
814
971
|
let inpList = inputs.list;
|
|
@@ -829,13 +986,18 @@ export class Lists {
|
|
|
829
986
|
return res;
|
|
830
987
|
}
|
|
831
988
|
/**
|
|
832
|
-
* Sorts numbers
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
* @
|
|
989
|
+
* Sorts numbers from lowest to highest, or from highest to lowest.
|
|
990
|
+
*
|
|
991
|
+
* Example: [5, 2, 8, 1, 9] ascending -> [1, 2, 5, 8, 9]; descending -> [9, 8, 5, 2, 1]
|
|
992
|
+
* @param inputs - The numbers, the direction and whether to copy
|
|
993
|
+
* @returns The sorted numbers
|
|
836
994
|
* @group sorting
|
|
837
995
|
* @shortname sort numbers
|
|
838
996
|
* @drawable false
|
|
997
|
+
* @example
|
|
998
|
+
* ```typescript
|
|
999
|
+
* const sorted = bitbybit.lists.sortNumber({ list: [5, 2, 8, 1, 9], orderAsc: true, clone: true });
|
|
1000
|
+
* ```
|
|
839
1001
|
*/
|
|
840
1002
|
sortNumber(inputs) {
|
|
841
1003
|
let res = inputs.list;
|
|
@@ -850,13 +1012,18 @@ export class Lists {
|
|
|
850
1012
|
}
|
|
851
1013
|
}
|
|
852
1014
|
/**
|
|
853
|
-
* Sorts
|
|
854
|
-
*
|
|
855
|
-
*
|
|
856
|
-
* @
|
|
1015
|
+
* Sorts texts alphabetically, from A to Z or from Z to A.
|
|
1016
|
+
*
|
|
1017
|
+
* Example: ['dog', 'apple', 'cat'] ascending -> ['apple', 'cat', 'dog']
|
|
1018
|
+
* @param inputs - The texts, the direction and whether to copy
|
|
1019
|
+
* @returns The sorted texts
|
|
857
1020
|
* @group sorting
|
|
858
1021
|
* @shortname sort texts
|
|
859
1022
|
* @drawable false
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* const sorted = bitbybit.lists.sortTexts({ list: ["dog", "apple", "cat"], orderAsc: true, clone: true });
|
|
1026
|
+
* ```
|
|
860
1027
|
*/
|
|
861
1028
|
sortTexts(inputs) {
|
|
862
1029
|
let res = inputs.list;
|
|
@@ -871,13 +1038,19 @@ export class Lists {
|
|
|
871
1038
|
}
|
|
872
1039
|
}
|
|
873
1040
|
/**
|
|
874
|
-
* Sorts objects by
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
*
|
|
1041
|
+
* Sorts objects by the number held in one of their properties.
|
|
1042
|
+
*
|
|
1043
|
+
* Example: [{age: 30}, {age: 20}, {age: 25}] by 'age' ascending -> [{age: 20}, {age: 25}, {age:
|
|
1044
|
+
* 30}]
|
|
1045
|
+
* @param inputs - The objects, the property to sort by, the direction and whether to copy
|
|
1046
|
+
* @returns The sorted objects
|
|
878
1047
|
* @group sorting
|
|
879
1048
|
* @shortname sort json objects
|
|
880
1049
|
* @drawable false
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* const byAge = bitbybit.lists.sortByPropValue({ list: [{ age: 30 }, { age: 20 }], property: "age", orderAsc: true, clone: true });
|
|
1053
|
+
* ```
|
|
881
1054
|
*/
|
|
882
1055
|
sortByPropValue(inputs) {
|
|
883
1056
|
let res = inputs.list;
|
|
@@ -892,13 +1065,20 @@ export class Lists {
|
|
|
892
1065
|
}
|
|
893
1066
|
}
|
|
894
1067
|
/**
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
1068
|
+
* Weaves several lists into one by taking the first item of each in turn, then the second of
|
|
1069
|
+
* each, and so on.
|
|
1070
|
+
*
|
|
1071
|
+
* A shorter list simply drops out once it runs dry. An empty list of lists throws an error.
|
|
1072
|
+
* Example: [[0, 1, 2], [3, 4, 5]] -> [0, 3, 1, 4, 2, 5]
|
|
1073
|
+
* @param inputs - The lists to weave together and whether to copy
|
|
1074
|
+
* @returns One list with the items alternating
|
|
899
1075
|
* @group transform
|
|
900
1076
|
* @shortname interleave lists
|
|
901
1077
|
* @drawable false
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```typescript
|
|
1080
|
+
* const woven = bitbybit.lists.interleave({ lists: [[0, 1, 2], [3, 4, 5]], clone: true });
|
|
1081
|
+
* ```
|
|
902
1082
|
*/
|
|
903
1083
|
interleave(inputs) {
|
|
904
1084
|
const lists = inputs.clone ? structuredClone(inputs.lists) : inputs.lists;
|