@bitbybit-dev/base 1.2.0 → 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.
Files changed (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -1,430 +1,610 @@
1
1
  import * as Inputs from "../inputs";
2
2
  /**
3
- * Contains various list methods.
4
- * <div>
5
- * <img src="../assets/images/blockly-images/math/math.svg" alt="Blockly Image"/>
6
- * </div>
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
- * Gets an item from the list at a specific position using zero-based indexing.
11
- * Example: From [10, 20, 30, 40], getting index 2 returns 30
12
- * @param inputs a list and an index
13
- * @returns item
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
- * Gets the first item from the list.
21
- * Example: From [10, 20, 30, 40], returns 10
22
- * @param inputs a list
23
- * @returns first item
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
- * Gets the last item from the list.
31
- * Example: From [10, 20, 30, 40], returns 40
32
- * @param inputs a list
33
- * @returns last item
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
- * Randomly keeps items from the list based on a probability threshold (0 to 1).
41
- * Example: From [1, 2, 3, 4, 5] with threshold 0.5, might return [1, 3, 5] (50% chance for each item)
42
- * @param inputs a list and a threshold for randomization of items to remove
43
- * @returns list with remaining items
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
- * Extracts a portion of the list between start and end positions (end is exclusive).
51
- * Example: From [10, 20, 30, 40, 50] with start=1 and end=4, returns [20, 30, 40]
52
- * @param inputs a list and start and end indexes
53
- * @returns sub list
54
- * @group get
55
- * @shortname sublist
56
- * @drawable false
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
- * Gets every nth item from the list, starting from an optional offset position.
61
- * Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=3 and offset=0, returns [0, 3, 6]
62
- * Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=2 and offset=1, returns [1, 3, 5, 7]
63
- * @param inputs a list and index
64
- * @returns list with filtered items
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
- * Filters items from the list using a repeating true/false pattern.
72
- * Example: From [0, 1, 2, 3, 4, 5] with pattern [true, true, false], returns [0, 1, 3, 4] (keeps items where pattern is true)
73
- * @param inputs a list and index
74
- * @returns list with filtered items
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
- * Merges elements from multiple lists at a specific nesting level, grouping elements by position.
82
- * Example: From [[0, 1, 2], [3, 4, 5]] at level 0, returns [[0, 3], [1, 4], [2, 5]]
83
- * @param inputs lists, level and flatten data
84
- * @returns list with merged lists and flattened lists
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
- * Finds the length of the longest list among multiple lists.
92
- * Example: From [[1, 2], [3, 4, 5, 6], [7]], returns 4 (length of [3, 4, 5, 6])
93
- * @param inputs a list of lists
94
- * @returns number of max length
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 items in the list.
102
- * Example: From [1, 2, 3, 4, 5], returns [5, 4, 3, 2, 1]
103
- * @param inputs a list and an index
104
- * @returns item
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
- * Randomly rearranges all items in the list (using Fisher-Yates algorithm).
112
- * Example: From [1, 2, 3, 4, 5], might return [3, 1, 5, 2, 4] (order varies each time)
113
- * @param inputs a list
114
- * @returns shuffled list
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
- * Transposes a 2D list by swapping rows and columns (all sublists must be equal length).
122
- * Example: From [[0, 1, 2], [3, 4, 5]], returns [[0, 3], [1, 4], [2, 5]]
123
- * @param inputs a list of lists to flip
124
- * @returns item
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 smaller lists of n elements each.
132
- * Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with n=3, returns [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
133
- * Example: From [0, 1, 2, 3, 4] with n=2 and keepRemainder=true, returns [[0, 1], [2, 3], [4]]
134
- * @param inputs a list
135
- * @returns items grouped in lists of n elements
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
- * Checks whether the list contains a specific item.
143
- * Example: List [10, 20, 30, 40] with item 30 returns true, with item 50 returns false
144
- * @param inputs a list and an item
145
- * @returns true if item is in list
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 (index) of the first occurrence of an item in the list.
153
- * Example: In [10, 20, 30, 20, 40], finding 20 returns 1 (first occurrence), finding 50 returns -1 (not found)
154
- * @param inputs a list and an item
155
- * @returns index of the item or -1 if not found
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
- * Determines the maximum nesting level (depth) of a list structure.
163
- * Example: [1, 2, 3] has depth 1, [[1, 2], [3, 4]] has depth 2, [[[1]]] has depth 3
164
- * @param inputs a list
165
- * @returns number of depth
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
- * Returns the number of items in the list.
173
- * Example: [10, 20, 30, 40, 50] returns 5, [] returns 0
174
- * @param inputs a length list
175
- * @returns a number
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 specific position in the list.
183
- * Example: In [10, 20, 30, 40], adding 99 at index 2 gives [10, 20, 99, 30, 40]
184
- * @param inputs a list, item and an index
185
- * @returns list with added item
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 multiple specified positions in the list.
193
- * Example: In [10, 20, 30], adding 99 at indexes [0, 2] gives [99, 10, 20, 99, 30]
194
- * @param inputs a list, item and an indexes
195
- * @returns list with added item
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 multiple items at corresponding positions (first item at first index, second item at second index, etc.).
203
- * Example: In [10, 20, 30], adding items [88, 99] at indexes [1, 2] gives [10, 88, 20, 99, 30]
204
- * @param inputs a list, items and an indexes
205
- * @returns list with added items
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 specific position in the list.
213
- * Example: From [10, 20, 30, 40, 50], removing index 2 gives [10, 20, 40, 50]
214
- * @param inputs a list and index
215
- * @returns list with removed item
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 from the list.
223
- * Example: From [10, 20, 30, 40], returns [20, 30, 40]
224
- * @param inputs a list
225
- * @returns list with first item removed
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 from the list.
233
- * Example: From [10, 20, 30, 40], returns [10, 20, 30]
234
- * @param inputs a list
235
- * @returns list with last item removed
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 counting from the end of the list (index 0 = last item, 1 = second-to-last, etc.).
243
- * Example: From [10, 20, 30, 40, 50], removing index 1 from end gives [10, 20, 30, 50] (removes 40)
244
- * @param inputs a list and index from end
245
- * @returns list with removed item
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 multiple specified positions from the list.
253
- * Example: From [10, 20, 30, 40, 50], removing indexes [1, 3] gives [10, 30, 50]
254
- * @param inputs a list and indexes
255
- * @returns list with removed items
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
- * Clears all items from the list, resulting in an empty list.
263
- * Example: From [10, 20, 30, 40], returns []
264
- * @param inputs a list
265
- * @returns The length is set to 0 and same array memory object is returned
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 from the list, starting from an optional offset position.
273
- * Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=3 and offset=0, returns [1, 2, 4, 5, 7, 8] (removes 0, 3, 6)
274
- * @param inputs a list and index
275
- * @returns list with removed item
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
- * Randomly removes items from the list based on a probability threshold (0 to 1).
283
- * Example: From [1, 2, 3, 4, 5] with threshold 0.5, might return [2, 4] (50% chance to remove each item)
284
- * @param inputs a list and a threshold for randomization of items to remove
285
- * @returns list with removed items
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 duplicate numbers from the list, keeping only the first occurrence of each value.
293
- * Example: From [1, 2, 3, 2, 4, 3, 5], returns [1, 2, 3, 4, 5]
294
- * @param inputs a list of numbers
295
- * @returns list with unique numbers
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 duplicate numbers that are within a specified tolerance range of each other.
303
- * Example: From [1.0, 1.001, 2.0, 2.002, 3.0] with tolerance 0.01, returns [1.0, 2.0, 3.0]
304
- * @param inputs a list of numbers and the tolerance
305
- * @returns list with unique numbers
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 duplicate items from the list using strict equality comparison (works with any type).
313
- * Example: From ['a', 'b', 'c', 'a', 'd', 'b'], returns ['a', 'b', 'c', 'd']
314
- * @param inputs a list
315
- * @returns list with unique items
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
- * Appends an item to the end of the list.
323
- * Example: To [10, 20, 30], adding 40 gives [10, 20, 30, 40]
324
- * @param inputs a list and an item
325
- * @returns list with added item
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 to the beginning of the list.
333
- * Example: To [10, 20, 30], prepending 5 gives [5, 10, 20, 30]
334
- * @param inputs a list and an item
335
- * @returns list with added item
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 either at the beginning or end of the list based on the position parameter.
343
- * Example: To [10, 20, 30], adding 5 at 'first' gives [5, 10, 20, 30], at 'last' gives [10, 20, 30, 5]
344
- * @param inputs a list, item and an option for first or last position
345
- * @returns list with added item
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
- * Combines multiple lists into a single list by joining them end-to-end.
353
- * Example: From [[1, 2], [3, 4], [5, 6]], returns [1, 2, 3, 4, 5, 6]
354
- * @param inputs lists to concatenate
355
- * @returns concatenated list
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
- * Creates a new empty list with no items.
363
- * Example: Returns []
364
- * @returns an empty array list
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
- * Creates a new list by repeating an item a specified number of times.
372
- * Example: Repeating 5 three times returns [5, 5, 5]
373
- * @param inputs an item to multiply
374
- * @returns list
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 cyclically until reaching a target list length.
382
- * Example: Pattern [1, 2, 3] with length 7 returns [1, 2, 3, 1, 2, 3, 1]
383
- * @param inputs a list to multiply and a length limit
384
- * @returns list
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 in ascending (lowest to highest) or descending (highest to lowest) order.
392
- * Example: [5, 2, 8, 1, 9] ascending returns [1, 2, 5, 8, 9], descending returns [9, 8, 5, 2, 1]
393
- * @param inputs a list of numbers to sort and an option for ascending or descending order
394
- * @returns list
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 text strings alphabetically in ascending (A to Z) or descending (Z to A) order.
402
- * Example: ['dog', 'apple', 'cat', 'banana'] ascending returns ['apple', 'banana', 'cat', 'dog']
403
- * @param inputs a list of texts to sort and an option for ascending or descending order
404
- * @returns list
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 comparing numeric values of a specified property.
412
- * Example: [{age: 30}, {age: 20}, {age: 25}] sorted by 'age' ascending returns [{age: 20}, {age: 25}, {age: 30}]
413
- * @param inputs a list to sort, a property to sort by and an option for ascending or descending order
414
- * @returns list
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
- * Combines multiple lists by alternating elements from each list (first from list1, first from list2, second from list1, etc.).
422
- * Example: From [[0, 1, 2], [3, 4, 5]], returns [0, 3, 1, 4, 2, 5]
423
- * @param inputs Lists to interleave
424
- * @returns Flattened interleaved list
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
  }