@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,430 +1,610 @@
|
|
|
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 declare 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<T>(inputs: Inputs.Lists.ListItemDto<T>): T;
|
|
19
25
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
26
|
+
* Reads the first item of the list.
|
|
27
|
+
*
|
|
28
|
+
* Example: [10, 20, 30, 40] -> 10
|
|
29
|
+
* @param inputs - The list and whether to copy the item
|
|
30
|
+
* @returns The first item
|
|
24
31
|
* @group get
|
|
25
32
|
* @shortname first item
|
|
26
33
|
* @drawable false
|
|
27
34
|
*/
|
|
28
35
|
getFirstItem<T>(inputs: Inputs.Lists.ListCloneDto<T>): T;
|
|
29
36
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
37
|
+
* Reads the last item of the list.
|
|
38
|
+
*
|
|
39
|
+
* Example: [10, 20, 30, 40] -> 40
|
|
40
|
+
* @param inputs - The list and whether to copy the item
|
|
41
|
+
* @returns The last item
|
|
34
42
|
* @group get
|
|
35
43
|
* @shortname last item
|
|
36
44
|
* @drawable false
|
|
37
45
|
*/
|
|
38
46
|
getLastItem<T>(inputs: Inputs.Lists.ListCloneDto<T>): T;
|
|
39
47
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
48
|
+
* Keeps each item of the list with a given probability and drops the rest, so the result
|
|
49
|
+
* differs on every call.
|
|
50
|
+
*
|
|
51
|
+
* Example: [1, 2, 3, 4, 5] with threshold 0.5 -> perhaps [1, 3, 5]
|
|
52
|
+
* @param inputs - The list, the probability of keeping an item from 0 to 1, and whether to copy
|
|
53
|
+
* @returns The items that were kept, in their original order
|
|
44
54
|
* @group get
|
|
45
55
|
* @shortname random get threshold
|
|
46
56
|
* @drawable false
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const some = bitbybit.lists.randomGetThreshold({ list: [1, 2, 3, 4, 5], threshold: 0.5, clone: true });
|
|
60
|
+
* ```
|
|
47
61
|
*/
|
|
48
62
|
randomGetThreshold<T>(inputs: Inputs.Lists.RandomThresholdDto<T>): T[];
|
|
49
63
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
* Cuts out the items from a start index up to, but not including, an end index.
|
|
65
|
+
*
|
|
66
|
+
* Example: [10, 20, 30, 40, 50] from 1 to 4 -> [20, 30, 40]
|
|
67
|
+
* @param inputs - The list, the start and end indexes, and whether to copy
|
|
68
|
+
* @returns The items in that range
|
|
69
|
+
* @group get
|
|
70
|
+
* @shortname sublist
|
|
71
|
+
* @drawable false
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const middle = bitbybit.lists.getSubList({ list: [10, 20, 30, 40, 50], indexStart: 1, indexEnd: 4, clone: true });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
58
77
|
getSubList<T>(inputs: Inputs.Lists.SubListDto<T>): T[];
|
|
59
78
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* Example:
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
79
|
+
* Keeps every nth item, starting from an offset.
|
|
80
|
+
*
|
|
81
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth 3 and offset 0 -> [0, 3, 6]; with nth 2 and
|
|
82
|
+
* offset 1 -> [1, 3, 5, 7]
|
|
83
|
+
* @param inputs - The list, the step, the offset to start from, and whether to copy
|
|
84
|
+
* @returns Every nth item, in order
|
|
65
85
|
* @group get
|
|
66
86
|
* @shortname every n-th
|
|
67
87
|
* @drawable false
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const everyThird = bitbybit.lists.getNthItem({ list: [0, 1, 2, 3, 4, 5, 6, 7, 8], nth: 3, offset: 0, clone: true });
|
|
91
|
+
* ```
|
|
68
92
|
*/
|
|
69
93
|
getNthItem<T>(inputs: Inputs.Lists.GetNthItemDto<T>): T[];
|
|
70
94
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
95
|
+
* Keeps the items where a repeating true/false pattern says true and drops the others.
|
|
96
|
+
*
|
|
97
|
+
* The pattern starts over when it runs out.
|
|
98
|
+
* Example: [0, 1, 2, 3, 4, 5] with pattern [true, true, false] -> [0, 1, 3, 4]
|
|
99
|
+
* @param inputs - The list and the pattern
|
|
100
|
+
* @returns The items the pattern kept, in order
|
|
75
101
|
* @group get
|
|
76
102
|
* @shortname by pattern
|
|
77
103
|
* @drawable false
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const kept = bitbybit.lists.getByPattern({ list: [0, 1, 2, 3, 4, 5], pattern: [true, true, false] });
|
|
107
|
+
* ```
|
|
78
108
|
*/
|
|
79
109
|
getByPattern<T>(inputs: Inputs.Lists.GetByPatternDto<T>): T[];
|
|
80
110
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
111
|
+
* Regroups nested lists by position: the first items of every list go together, then the second
|
|
112
|
+
* items, and so on.
|
|
113
|
+
*
|
|
114
|
+
* `level` says how many levels of nesting to flatten inside each list first; 0 regroups them as
|
|
115
|
+
* they are.
|
|
116
|
+
* Example: [[0, 1, 2], [3, 4, 5]] at level 0 -> [[0, 3], [1, 4], [2, 5]]
|
|
117
|
+
* @param inputs - The lists and the depth at which to regroup
|
|
118
|
+
* @returns The regrouped lists
|
|
85
119
|
* @group get
|
|
86
120
|
* @shortname merge levels
|
|
87
121
|
* @drawable false
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const columns = bitbybit.lists.mergeElementsOfLists({ lists: [[0, 1, 2], [3, 4, 5]], level: 0 });
|
|
125
|
+
* ```
|
|
88
126
|
*/
|
|
89
127
|
mergeElementsOfLists<T>(inputs: Inputs.Lists.MergeElementsOfLists<T[]>): T[];
|
|
90
128
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
129
|
+
* Measures the longest list among several.
|
|
130
|
+
*
|
|
131
|
+
* Example: [[1, 2], [3, 4, 5, 6], [7]] -> 4
|
|
132
|
+
* @param inputs - The lists to measure
|
|
133
|
+
* @returns The length of the longest one
|
|
95
134
|
* @group get
|
|
96
135
|
* @shortname longest list length
|
|
97
136
|
* @drawable false
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const longest = bitbybit.lists.getLongestListLength({ lists: [[1, 2], [3, 4, 5, 6], [7]] });
|
|
140
|
+
* ```
|
|
98
141
|
*/
|
|
99
142
|
getLongestListLength<T>(inputs: Inputs.Lists.GetLongestListLength<T[]>): number;
|
|
100
143
|
/**
|
|
101
|
-
* Reverses the order of
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @
|
|
144
|
+
* Reverses the order of the items.
|
|
145
|
+
*
|
|
146
|
+
* Example: [1, 2, 3, 4, 5] -> [5, 4, 3, 2, 1]
|
|
147
|
+
* @param inputs - The list and whether to copy it first
|
|
148
|
+
* @returns The reversed list
|
|
105
149
|
* @group edit
|
|
106
150
|
* @shortname reverse
|
|
107
151
|
* @drawable false
|
|
108
152
|
*/
|
|
109
153
|
reverse<T>(inputs: Inputs.Lists.ListCloneDto<T>): T[];
|
|
110
154
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
155
|
+
* Puts the items in a random order, different on every call.
|
|
156
|
+
*
|
|
157
|
+
* Example: [1, 2, 3, 4, 5] -> perhaps [3, 1, 5, 2, 4]
|
|
158
|
+
* @param inputs - The list and whether to copy it first
|
|
159
|
+
* @returns The shuffled list
|
|
115
160
|
* @group edit
|
|
116
161
|
* @shortname shuffle
|
|
117
162
|
* @drawable false
|
|
118
163
|
*/
|
|
119
164
|
shuffle<T>(inputs: Inputs.Lists.ListCloneDto<T>): T[];
|
|
120
165
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
166
|
+
* Turns a list of lists on its side: rows become columns and columns become rows.
|
|
167
|
+
*
|
|
168
|
+
* All the inner lists must have the same length.
|
|
169
|
+
* Example: [[0, 1, 2], [3, 4, 5]] -> [[0, 3], [1, 4], [2, 5]]
|
|
170
|
+
* @param inputs - The list of lists and whether to copy it first
|
|
171
|
+
* @returns The transposed list of lists
|
|
125
172
|
* @group edit
|
|
126
173
|
* @shortname flip lists
|
|
127
174
|
* @drawable false
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const columns = bitbybit.lists.flipLists({ list: [[0, 1, 2], [3, 4, 5]], clone: true });
|
|
178
|
+
* ```
|
|
128
179
|
*/
|
|
129
180
|
flipLists<T>(inputs: Inputs.Lists.ListCloneDto<T[]>): T[][];
|
|
130
181
|
/**
|
|
131
|
-
* Splits the list into
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
182
|
+
* Splits the list into groups of n items.
|
|
183
|
+
*
|
|
184
|
+
* Items left over at the end are dropped unless `keepRemainder` is on, which adds them as a
|
|
185
|
+
* shorter last group.
|
|
186
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] in groups of 3 -> [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
|
|
187
|
+
* @param inputs - The list, the group size and whether to keep a partial last group
|
|
188
|
+
* @returns The groups, in order
|
|
136
189
|
* @group edit
|
|
137
190
|
* @shortname group elements
|
|
138
191
|
* @drawable false
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* const pairs = bitbybit.lists.groupNth({ list: [0, 1, 2, 3, 4], nrElements: 2, keepRemainder: true });
|
|
195
|
+
* ```
|
|
139
196
|
*/
|
|
140
197
|
groupNth<T>(inputs: Inputs.Lists.GroupListDto<T>): T[][];
|
|
141
198
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
199
|
+
* Tells whether an item is in the list.
|
|
200
|
+
*
|
|
201
|
+
* Items are compared by identity, so an object is found only if the very same object is in the
|
|
202
|
+
* list.
|
|
203
|
+
* Example: [10, 20, 30, 40] includes 30 -> true, includes 50 -> false
|
|
204
|
+
* @param inputs - The list and the item to look for
|
|
205
|
+
* @returns True when the item is in the list
|
|
146
206
|
* @group get
|
|
147
207
|
* @shortname contains item
|
|
148
208
|
* @drawable false
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const found = bitbybit.lists.includes({ list: [10, 20, 30, 40], item: 30 });
|
|
212
|
+
* ```
|
|
149
213
|
*/
|
|
150
214
|
includes<T>(inputs: Inputs.Lists.IncludesDto<T>): boolean;
|
|
151
215
|
/**
|
|
152
|
-
* Finds the position
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* @
|
|
216
|
+
* Finds the position of the first occurrence of an item, or -1 when it is not in the list.
|
|
217
|
+
*
|
|
218
|
+
* Example: [10, 20, 30, 20, 40] finding 20 -> 1, finding 50 -> -1
|
|
219
|
+
* @param inputs - The list and the item to look for
|
|
220
|
+
* @returns The 0-based index, or -1
|
|
156
221
|
* @group get
|
|
157
222
|
* @shortname find index
|
|
158
223
|
* @drawable false
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const where = bitbybit.lists.findIndex({ list: [10, 20, 30, 20, 40], item: 20 });
|
|
227
|
+
* ```
|
|
159
228
|
*/
|
|
160
229
|
findIndex<T>(inputs: Inputs.Lists.IncludesDto<T>): number;
|
|
161
230
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @
|
|
231
|
+
* Measures how deeply lists are nested inside the list.
|
|
232
|
+
*
|
|
233
|
+
* Example: [1, 2, 3] -> 1, [[1, 2], [3, 4]] -> 2, [[[1]]] -> 3
|
|
234
|
+
* @param inputs - The list
|
|
235
|
+
* @returns The number of nesting levels
|
|
166
236
|
* @group get
|
|
167
237
|
* @shortname max list depth
|
|
168
238
|
* @drawable false
|
|
169
239
|
*/
|
|
170
240
|
getListDepth(inputs: Inputs.Lists.ListCloneDto<[]>): number;
|
|
171
241
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
242
|
+
* Counts the items in the list.
|
|
243
|
+
*
|
|
244
|
+
* Example: [10, 20, 30, 40, 50] -> 5, [] -> 0
|
|
245
|
+
* @param inputs - The list
|
|
246
|
+
* @returns The number of items
|
|
176
247
|
* @group get
|
|
177
248
|
* @shortname list length
|
|
178
249
|
* @drawable false
|
|
179
250
|
*/
|
|
180
251
|
listLength<T>(inputs: Inputs.Lists.ListCloneDto<T>): number;
|
|
181
252
|
/**
|
|
182
|
-
* Inserts an item at a
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* @
|
|
253
|
+
* Inserts an item at a position; the items from that position on shift up by one.
|
|
254
|
+
*
|
|
255
|
+
* Example: [10, 20, 30, 40] with 99 at index 2 -> [10, 20, 99, 30, 40]
|
|
256
|
+
* @param inputs - The list, the item, the index and whether to copy
|
|
257
|
+
* @returns The list with the item inserted
|
|
186
258
|
* @group add
|
|
187
259
|
* @shortname add item
|
|
188
260
|
* @drawable false
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const longer = bitbybit.lists.addItemAtIndex({ list: [10, 20, 30, 40], item: 99, index: 2, clone: true });
|
|
264
|
+
* ```
|
|
189
265
|
*/
|
|
190
266
|
addItemAtIndex<T>(inputs: Inputs.Lists.AddItemAtIndexDto<T>): T[];
|
|
191
267
|
/**
|
|
192
|
-
* Inserts the same item at
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* @
|
|
268
|
+
* Inserts the same item at several positions of the original list.
|
|
269
|
+
*
|
|
270
|
+
* Example: [10, 20, 30] with 99 at indexes [0, 2] -> [99, 10, 20, 99, 30]
|
|
271
|
+
* @param inputs - The list, the item, the indexes and whether to copy
|
|
272
|
+
* @returns The list with the item inserted at each index
|
|
196
273
|
* @group add
|
|
197
274
|
* @shortname add item at indexes
|
|
198
275
|
* @drawable false
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const marked = bitbybit.lists.addItemAtIndexes({ list: [10, 20, 30], item: 99, indexes: [0, 2], clone: true });
|
|
279
|
+
* ```
|
|
199
280
|
*/
|
|
200
281
|
addItemAtIndexes<T>(inputs: Inputs.Lists.AddItemAtIndexesDto<T>): T[];
|
|
201
282
|
/**
|
|
202
|
-
* Inserts
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
283
|
+
* Inserts several items, the first at the first index, the second at the second, and so on, all
|
|
284
|
+
* counted on the original list.
|
|
285
|
+
*
|
|
286
|
+
* The indexes must be in ascending order and there must be one per item, or an error is thrown.
|
|
287
|
+
* Example: [10, 20, 30] with items [88, 99] at indexes [1, 2] -> [10, 88, 20, 99, 30]
|
|
288
|
+
* @param inputs - The list, the items, one index per item and whether to copy
|
|
289
|
+
* @returns The list with the items inserted
|
|
206
290
|
* @group add
|
|
207
291
|
* @shortname add items
|
|
208
292
|
* @drawable false
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const merged = bitbybit.lists.addItemsAtIndexes({ list: [10, 20, 30], items: [88, 99], indexes: [1, 2], clone: true });
|
|
296
|
+
* ```
|
|
209
297
|
*/
|
|
210
298
|
addItemsAtIndexes<T>(inputs: Inputs.Lists.AddItemsAtIndexesDto<T>): T[];
|
|
211
299
|
/**
|
|
212
|
-
* Removes the item at a
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* @
|
|
300
|
+
* Removes the item at a position.
|
|
301
|
+
*
|
|
302
|
+
* Example: [10, 20, 30, 40, 50] removing index 2 -> [10, 20, 40, 50]
|
|
303
|
+
* @param inputs - The list, the index and whether to copy
|
|
304
|
+
* @returns The list without that item
|
|
216
305
|
* @group remove
|
|
217
306
|
* @shortname remove item
|
|
218
307
|
* @drawable false
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const shorter = bitbybit.lists.removeItemAtIndex({ list: [10, 20, 30, 40, 50], index: 2, clone: true });
|
|
311
|
+
* ```
|
|
219
312
|
*/
|
|
220
313
|
removeItemAtIndex<T>(inputs: Inputs.Lists.RemoveItemAtIndexDto<T>): T[];
|
|
221
314
|
/**
|
|
222
|
-
* Removes the first item
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* @
|
|
315
|
+
* Removes the first item.
|
|
316
|
+
*
|
|
317
|
+
* Example: [10, 20, 30, 40] -> [20, 30, 40]
|
|
318
|
+
* @param inputs - The list and whether to copy it first
|
|
319
|
+
* @returns The list without its first item
|
|
226
320
|
* @group remove
|
|
227
321
|
* @shortname remove first item
|
|
228
322
|
* @drawable false
|
|
229
323
|
*/
|
|
230
324
|
removeFirstItem<T>(inputs: Inputs.Lists.ListCloneDto<T>): T[];
|
|
231
325
|
/**
|
|
232
|
-
* Removes the last item
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* @
|
|
326
|
+
* Removes the last item.
|
|
327
|
+
*
|
|
328
|
+
* Example: [10, 20, 30, 40] -> [10, 20, 30]
|
|
329
|
+
* @param inputs - The list and whether to copy it first
|
|
330
|
+
* @returns The list without its last item
|
|
236
331
|
* @group remove
|
|
237
332
|
* @shortname remove last item
|
|
238
333
|
* @drawable false
|
|
239
334
|
*/
|
|
240
335
|
removeLastItem<T>(inputs: Inputs.Lists.ListCloneDto<T>): T[];
|
|
241
336
|
/**
|
|
242
|
-
* Removes an item
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* @
|
|
337
|
+
* Removes an item counted from the end: index 0 is the last item, 1 the one before it.
|
|
338
|
+
*
|
|
339
|
+
* Example: [10, 20, 30, 40, 50] removing index 1 from the end -> [10, 20, 30, 50]
|
|
340
|
+
* @param inputs - The list, the index from the end and whether to copy
|
|
341
|
+
* @returns The list without that item
|
|
246
342
|
* @group remove
|
|
247
343
|
* @shortname remove item from end
|
|
248
344
|
* @drawable false
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const shorter = bitbybit.lists.removeItemAtIndexFromEnd({ list: [10, 20, 30, 40, 50], index: 1, clone: true });
|
|
348
|
+
* ```
|
|
249
349
|
*/
|
|
250
350
|
removeItemAtIndexFromEnd<T>(inputs: Inputs.Lists.RemoveItemAtIndexDto<T>): T[];
|
|
251
351
|
/**
|
|
252
|
-
* Removes items at
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* @
|
|
352
|
+
* Removes the items at several positions, all counted on the original list.
|
|
353
|
+
*
|
|
354
|
+
* Example: [10, 20, 30, 40, 50] removing indexes [1, 3] -> [10, 30, 50]
|
|
355
|
+
* @param inputs - The list, the indexes and whether to copy
|
|
356
|
+
* @returns The list without those items
|
|
256
357
|
* @group remove
|
|
257
358
|
* @shortname remove items
|
|
258
359
|
* @drawable false
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const kept = bitbybit.lists.removeItemsAtIndexes({ list: [10, 20, 30, 40, 50], indexes: [1, 3], clone: true });
|
|
363
|
+
* ```
|
|
259
364
|
*/
|
|
260
365
|
removeItemsAtIndexes<T>(inputs: Inputs.Lists.RemoveItemsAtIndexesDto<T>): T[];
|
|
261
366
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @
|
|
367
|
+
* Empties the list it is given, in place: the same array comes back with no items in it.
|
|
368
|
+
*
|
|
369
|
+
* Example: [10, 20, 30, 40] -> []
|
|
370
|
+
* @param inputs - The list to empty
|
|
371
|
+
* @returns The same list, now empty
|
|
266
372
|
* @group remove
|
|
267
373
|
* @shortname remove all items
|
|
268
374
|
* @drawable false
|
|
269
375
|
*/
|
|
270
376
|
removeAllItems<T>(inputs: Inputs.Lists.ListDto<T>): T[];
|
|
271
377
|
/**
|
|
272
|
-
* Removes every nth item
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* @
|
|
378
|
+
* Removes every nth item, starting from an offset.
|
|
379
|
+
*
|
|
380
|
+
* Example: [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth 3 and offset 0 -> [1, 2, 4, 5, 7, 8]
|
|
381
|
+
* @param inputs - The list, the step, the offset to start from and whether to copy
|
|
382
|
+
* @returns The list without every nth item
|
|
276
383
|
* @group remove
|
|
277
384
|
* @shortname every n-th
|
|
278
385
|
* @drawable false
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* const thinned = bitbybit.lists.removeNthItem({ list: [0, 1, 2, 3, 4, 5, 6, 7, 8], nth: 3, offset: 0, clone: true });
|
|
389
|
+
* ```
|
|
279
390
|
*/
|
|
280
391
|
removeNthItem<T>(inputs: Inputs.Lists.RemoveNthItemDto<T>): T[];
|
|
281
392
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
393
|
+
* Drops each item of the list with a given probability and keeps the rest, so the result
|
|
394
|
+
* differs on every call.
|
|
395
|
+
*
|
|
396
|
+
* Example: [1, 2, 3, 4, 5] with threshold 0.5 -> perhaps [2, 4]
|
|
397
|
+
* @param inputs - The list, the probability of dropping an item from 0 to 1, and whether to copy
|
|
398
|
+
* @returns The items that survived, in their original order
|
|
286
399
|
* @group remove
|
|
287
400
|
* @shortname random remove threshold
|
|
288
401
|
* @drawable false
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* const some = bitbybit.lists.randomRemoveThreshold({ list: [1, 2, 3, 4, 5], threshold: 0.5, clone: true });
|
|
405
|
+
* ```
|
|
289
406
|
*/
|
|
290
407
|
randomRemoveThreshold<T>(inputs: Inputs.Lists.RandomThresholdDto<T>): T[];
|
|
291
408
|
/**
|
|
292
|
-
* Removes
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* @
|
|
409
|
+
* Removes repeated numbers, keeping the first occurrence of each.
|
|
410
|
+
*
|
|
411
|
+
* Example: [1, 2, 3, 2, 4, 3, 5] -> [1, 2, 3, 4, 5]
|
|
412
|
+
* @param inputs - The numbers and whether to copy
|
|
413
|
+
* @returns The numbers without repeats, in their original order
|
|
296
414
|
* @group remove
|
|
297
415
|
* @shortname remove duplicate numbers
|
|
298
416
|
* @drawable false
|
|
299
417
|
*/
|
|
300
418
|
removeDuplicateNumbers(inputs: Inputs.Lists.RemoveDuplicatesDto<number>): number[];
|
|
301
419
|
/**
|
|
302
|
-
* Removes
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
420
|
+
* Removes numbers that are within a tolerance of one already kept, so values that differ only
|
|
421
|
+
* by floating-point noise count as the same.
|
|
422
|
+
*
|
|
423
|
+
* Example: [1.0, 1.001, 2.0, 2.002, 3.0] with tolerance 0.01 -> [1.0, 2.0, 3.0]
|
|
424
|
+
* @param inputs - The numbers, the tolerance and whether to copy
|
|
425
|
+
* @returns The numbers without near-repeats, in their original order
|
|
306
426
|
* @group remove
|
|
307
427
|
* @shortname remove duplicates tol
|
|
308
428
|
* @drawable false
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const distinct = bitbybit.lists.removeDuplicateNumbersTolerance({ list: [1.0, 1.001, 2.0], tolerance: 0.01, clone: true });
|
|
432
|
+
* ```
|
|
309
433
|
*/
|
|
310
434
|
removeDuplicateNumbersTolerance(inputs: Inputs.Lists.RemoveDuplicatesToleranceDto<number>): number[];
|
|
311
435
|
/**
|
|
312
|
-
* Removes
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
436
|
+
* Removes repeated items of any kind, keeping the first occurrence of each.
|
|
437
|
+
*
|
|
438
|
+
* Items are compared by identity, so two equal-looking objects both stay.
|
|
439
|
+
* Example: ['a', 'b', 'c', 'a', 'd', 'b'] -> ['a', 'b', 'c', 'd']
|
|
440
|
+
* @param inputs - The list and whether to copy
|
|
441
|
+
* @returns The list without repeats, in its original order
|
|
316
442
|
* @group remove
|
|
317
443
|
* @shortname remove duplicates
|
|
318
444
|
* @drawable false
|
|
319
445
|
*/
|
|
320
446
|
removeDuplicates<T>(inputs: Inputs.Lists.RemoveDuplicatesDto<T>): T[];
|
|
321
447
|
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* @
|
|
448
|
+
* Adds an item at the end of the list.
|
|
449
|
+
*
|
|
450
|
+
* Example: [10, 20, 30] adding 40 -> [10, 20, 30, 40]
|
|
451
|
+
* @param inputs - The list, the item and whether to copy
|
|
452
|
+
* @returns The list with the item at its end
|
|
326
453
|
* @group add
|
|
327
454
|
* @shortname add item to list
|
|
328
455
|
* @drawable false
|
|
456
|
+
* @example
|
|
457
|
+
* ```typescript
|
|
458
|
+
* const longer = bitbybit.lists.addItem({ list: [10, 20, 30], item: 40, clone: true });
|
|
459
|
+
* ```
|
|
329
460
|
*/
|
|
330
461
|
addItem<T>(inputs: Inputs.Lists.AddItemDto<T>): T[];
|
|
331
462
|
/**
|
|
332
|
-
* Adds an item
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* @
|
|
463
|
+
* Adds an item at the start of the list.
|
|
464
|
+
*
|
|
465
|
+
* Example: [10, 20, 30] prepending 5 -> [5, 10, 20, 30]
|
|
466
|
+
* @param inputs - The list, the item and whether to copy
|
|
467
|
+
* @returns The list with the item at its start
|
|
336
468
|
* @group add
|
|
337
469
|
* @shortname prepend item to list
|
|
338
470
|
* @drawable false
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* const longer = bitbybit.lists.prependItem({ list: [10, 20, 30], item: 5, clone: true });
|
|
474
|
+
* ```
|
|
339
475
|
*/
|
|
340
476
|
prependItem<T>(inputs: Inputs.Lists.AddItemDto<T>): T[];
|
|
341
477
|
/**
|
|
342
|
-
* Adds an item
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* @
|
|
478
|
+
* Adds an item at the start or at the end of the list, as chosen.
|
|
479
|
+
*
|
|
480
|
+
* Example: [10, 20, 30] adding 5 first -> [5, 10, 20, 30]; last -> [10, 20, 30, 5]
|
|
481
|
+
* @param inputs - The list, the item, the position and whether to copy
|
|
482
|
+
* @returns The list with the item added
|
|
346
483
|
* @group add
|
|
347
484
|
* @shortname item at first or last
|
|
348
485
|
* @drawable false
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* const longer = bitbybit.lists.addItemFirstLast({ list: [10, 20, 30], item: 5, position: Bit.Inputs.Lists.firstLastEnum.first, clone: true });
|
|
489
|
+
* ```
|
|
349
490
|
*/
|
|
350
491
|
addItemFirstLast<T>(inputs: Inputs.Lists.AddItemFirstLastDto<T>): T[];
|
|
351
492
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @
|
|
493
|
+
* Joins several lists into one, end to end.
|
|
494
|
+
*
|
|
495
|
+
* Example: [[1, 2], [3, 4], [5, 6]] -> [1, 2, 3, 4, 5, 6]
|
|
496
|
+
* @param inputs - The lists to join and whether to copy
|
|
497
|
+
* @returns One list with all the items
|
|
356
498
|
* @group add
|
|
357
499
|
* @shortname concatenate lists
|
|
358
500
|
* @drawable false
|
|
501
|
+
* @example
|
|
502
|
+
* ```typescript
|
|
503
|
+
* const all = bitbybit.lists.concatenate({ lists: [[1, 2], [3, 4], [5, 6]], clone: true });
|
|
504
|
+
* ```
|
|
359
505
|
*/
|
|
360
506
|
concatenate<T>(inputs: Inputs.Lists.ConcatenateDto<T>): T[];
|
|
361
507
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
508
|
+
* Makes a new list with nothing in it.
|
|
509
|
+
*
|
|
510
|
+
* Example: -> []
|
|
511
|
+
* @returns An empty list
|
|
365
512
|
* @group create
|
|
366
513
|
* @shortname empty list
|
|
367
514
|
* @drawable false
|
|
368
515
|
*/
|
|
369
516
|
createEmptyList(): [];
|
|
370
517
|
/**
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* @
|
|
518
|
+
* Makes a list that holds the same item a number of times.
|
|
519
|
+
*
|
|
520
|
+
* Example: 5 three times -> [5, 5, 5]
|
|
521
|
+
* @param inputs - The item and how many times to repeat it
|
|
522
|
+
* @returns The list of repeats
|
|
375
523
|
* @group create
|
|
376
524
|
* @shortname repeat
|
|
377
525
|
* @drawable false
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const fives = bitbybit.lists.repeat({ item: 5, times: 3 });
|
|
529
|
+
* ```
|
|
378
530
|
*/
|
|
379
531
|
repeat<T>(inputs: Inputs.Lists.MultiplyItemDto<T>): T[];
|
|
380
532
|
/**
|
|
381
|
-
* Repeats a pattern of items
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
* @
|
|
533
|
+
* Repeats a pattern of items over and over until the list reaches a given length.
|
|
534
|
+
*
|
|
535
|
+
* Example: [1, 2, 3] to length 7 -> [1, 2, 3, 1, 2, 3, 1]
|
|
536
|
+
* @param inputs - The pattern, the length to reach and whether to copy
|
|
537
|
+
* @returns The repeated pattern, cut to the length
|
|
385
538
|
* @group create
|
|
386
539
|
* @shortname repeat in pattern
|
|
387
540
|
* @drawable false
|
|
541
|
+
* @example
|
|
542
|
+
* ```typescript
|
|
543
|
+
* const cycle = bitbybit.lists.repeatInPattern({ list: [1, 2, 3], lengthLimit: 7, clone: true });
|
|
544
|
+
* ```
|
|
388
545
|
*/
|
|
389
546
|
repeatInPattern<T>(inputs: Inputs.Lists.RepeatInPatternDto<T>): T[];
|
|
390
547
|
/**
|
|
391
|
-
* Sorts numbers
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* @
|
|
548
|
+
* Sorts numbers from lowest to highest, or from highest to lowest.
|
|
549
|
+
*
|
|
550
|
+
* Example: [5, 2, 8, 1, 9] ascending -> [1, 2, 5, 8, 9]; descending -> [9, 8, 5, 2, 1]
|
|
551
|
+
* @param inputs - The numbers, the direction and whether to copy
|
|
552
|
+
* @returns The sorted numbers
|
|
395
553
|
* @group sorting
|
|
396
554
|
* @shortname sort numbers
|
|
397
555
|
* @drawable false
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* const sorted = bitbybit.lists.sortNumber({ list: [5, 2, 8, 1, 9], orderAsc: true, clone: true });
|
|
559
|
+
* ```
|
|
398
560
|
*/
|
|
399
561
|
sortNumber(inputs: Inputs.Lists.SortDto<number>): number[];
|
|
400
562
|
/**
|
|
401
|
-
* Sorts
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* @
|
|
563
|
+
* Sorts texts alphabetically, from A to Z or from Z to A.
|
|
564
|
+
*
|
|
565
|
+
* Example: ['dog', 'apple', 'cat'] ascending -> ['apple', 'cat', 'dog']
|
|
566
|
+
* @param inputs - The texts, the direction and whether to copy
|
|
567
|
+
* @returns The sorted texts
|
|
405
568
|
* @group sorting
|
|
406
569
|
* @shortname sort texts
|
|
407
570
|
* @drawable false
|
|
571
|
+
* @example
|
|
572
|
+
* ```typescript
|
|
573
|
+
* const sorted = bitbybit.lists.sortTexts({ list: ["dog", "apple", "cat"], orderAsc: true, clone: true });
|
|
574
|
+
* ```
|
|
408
575
|
*/
|
|
409
576
|
sortTexts(inputs: Inputs.Lists.SortDto<string>): string[];
|
|
410
577
|
/**
|
|
411
|
-
* Sorts objects by
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
578
|
+
* Sorts objects by the number held in one of their properties.
|
|
579
|
+
*
|
|
580
|
+
* Example: [{age: 30}, {age: 20}, {age: 25}] by 'age' ascending -> [{age: 20}, {age: 25}, {age:
|
|
581
|
+
* 30}]
|
|
582
|
+
* @param inputs - The objects, the property to sort by, the direction and whether to copy
|
|
583
|
+
* @returns The sorted objects
|
|
415
584
|
* @group sorting
|
|
416
585
|
* @shortname sort json objects
|
|
417
586
|
* @drawable false
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* const byAge = bitbybit.lists.sortByPropValue({ list: [{ age: 30 }, { age: 20 }], property: "age", orderAsc: true, clone: true });
|
|
590
|
+
* ```
|
|
418
591
|
*/
|
|
419
592
|
sortByPropValue(inputs: Inputs.Lists.SortJsonDto<any>): any[];
|
|
420
593
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
594
|
+
* Weaves several lists into one by taking the first item of each in turn, then the second of
|
|
595
|
+
* each, and so on.
|
|
596
|
+
*
|
|
597
|
+
* A shorter list simply drops out once it runs dry. An empty list of lists throws an error.
|
|
598
|
+
* Example: [[0, 1, 2], [3, 4, 5]] -> [0, 3, 1, 4, 2, 5]
|
|
599
|
+
* @param inputs - The lists to weave together and whether to copy
|
|
600
|
+
* @returns One list with the items alternating
|
|
425
601
|
* @group transform
|
|
426
602
|
* @shortname interleave lists
|
|
427
603
|
* @drawable false
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* const woven = bitbybit.lists.interleave({ lists: [[0, 1, 2], [3, 4, 5]], clone: true });
|
|
607
|
+
* ```
|
|
428
608
|
*/
|
|
429
609
|
interleave<T>(inputs: Inputs.Lists.InterleaveDto<T>): T[];
|
|
430
610
|
}
|