@@ -64,7 +64,7 @@ getPublicArray(array = []): PublicArray
64
64
#### notEmpty: boolean (read-only)
65
65
66
66
#### filter: PublicArrayFilter (read-only)
67
- ###### This has methods that narrow down the content of the array and return the PublicArrayFilter instance:
67
+ ###### Has methods that narrow down the content of the array and return the PublicArrayFilter instance:
68
68
```
69
69
filter.byTest(testFunction): PublicArrayFilter
70
70
// Narrows down the array to only the values that pass testFunction.
@@ -77,7 +77,7 @@ filter.byType(
77
77
```
78
78
79
79
#### getConverted: PublicArrayGetterConverter (read-only)
80
- ###### This has the Array methods .map() and .reduce() , but renamed to .each() and .toOne() , respectively. None of them modify the array.
80
+ ###### Has the Array methods .map() and .reduce() , but renamed to .each() and .toOne() , respectively. None of them modify the array.
81
81
```
82
82
getConverted.toOne(
83
83
reducingFunction: ((previousValue: any, currentValue: any, index?, array?) => any)
@@ -89,7 +89,7 @@ getConverted.each(mappingFunction: ((item, index?, array?) => any)): any[]
89
89
```
90
90
91
91
#### get: PublicArrayGetter (read-only)
92
- ###### This has methods that return items copied from the array. None of them modify the array.
92
+ ###### Has methods that return items copied from the array. None of them modify the array.
93
93
```
94
94
get.copy(): any[]
95
95
// Returns independent copy of the array.
@@ -164,7 +164,7 @@ get.byType(
164
164
```
165
165
166
166
#### getAndRemove: PublicArrayGetterRemover (read-only)
167
- ###### This has methods that both remove and return items from the array.
167
+ ###### Has methods that both remove and return items from the array:
168
168
```
169
169
getAndRemove.byIndex(index): any
170
170
// index can be negative or positive.
@@ -234,8 +234,92 @@ getAndRemove.byType(
234
234
235
235
236
236
#### insert: PublicArrayInserter (read-only)
237
+ ###### Has methods that increase the length of the array and return the PublicArrayInserter instance:
238
+ ```
239
+ insert.at(index, values: any[]): PublicArrayInserter
240
+ // inserts values at index. index can be negative or positive.
241
+
242
+ insert.middle(values: any[], offset = 0): PublicArrayInserter
243
+ // inserts values in middle of the array.
244
+ // By default, if the array has odd number of items, values will be inserted just before the
245
+ // middle item. If you want to change the insert position, set the optional offset parameter to +
246
+ // or - whatever integer you want.
247
+ ```
237
248
238
249
#### remove: PublicArrayRemover (read-only)
250
+ ###### Has methods that all remove items from the array and return the PublicArrayRemover instance:
251
+ ```
252
+ remove.byIndex(index): this
253
+ // index can be negative or positive.
254
+
255
+ remove.byIndexes(indexes): this
256
+ // indexes can be negative or positive.
257
+
258
+ remove.adjacentAt(startingIndex, numItemsToRemove): this
259
+ // startingIndex can be negative or positive. Removes adjacent items.
260
+
261
+ remove.adjacentToValue(info): this
262
+ /************
263
+ Removes adjacent items including, or near, a particular value.
264
+ Only applies to the first instance of value found in array.
265
+ The parameter 'info' is an object that looks like this:
266
+ {
267
+ value: any except object (the value to search for in the array),
268
+ offset: integer (tells function where, in relation to value, to begin selecting adjacent
269
+ items to remove. If offset is zero, the selection will begin with value.)
270
+ howMany: integer greater than zero (it's how many adjacent items to remove)
271
+ }
272
+ Example:
273
+ // arr.data is [1,2,3,4,5,6,7,8,9,10]
274
+ arr.remove.adjacentToValue({value:5, offset: -2, howMany:3});
275
+ // arr.data is now [1,2,6,7,8,9,10]
276
+ *************/
277
+
278
+ remove.head(numItemsToRemove): this
279
+ // Removes numItemsToRemove from array's beginning.
280
+
281
+ remove.tail(numItemsToRemove): this
282
+ // Removes numItemsToRemove from array's end.
283
+
284
+ remove.between(numItemsToKeepAtEachEnd): this
285
+ // Removes everything between numItemsToKeepAtEachEnd.
286
+ // i.e., if numItemsToKeepAtEachEnd = 2, then only the first 2 items and last 2 items will remain.
287
+
288
+ remove.firstOf(value): this
289
+ // Removes first instance of value. value cannot be object (that applies to all functions here
290
+ // with a parameter called 'value').
291
+
292
+ remove.firstOfEach(values: any[]): this
293
+ // Removes first instance of each value. values cannot contain object (that applies to all functions
294
+ // here with a parameter called 'values').
295
+
296
+ remove.allOf(value): this
297
+ // Removes all instances of value.
298
+
299
+ remove.allOfEach(values: any[]): this
300
+ // Removes all instances of each value.
301
+
302
+ remove.allAfterFirst(value: any): this
303
+ // Removes all items after first instance of value.
304
+
305
+ remove.allBeforeFirst(value: any): this
306
+ // Removes all items before first instance of value.
307
+
308
+ remove.allAfterLast(value): this
309
+ // Removes all items after last instance of value.
310
+
311
+ remove.allBeforeLast(value): this
312
+ // Removes all items before last instance of value.
313
+
314
+ remove.duplicates(): this
315
+
316
+ remove.byTest(testFunction: (currentItem, currentIndex?, array?) => boolean): this
317
+ // if currentItem passes test, it is removed.
318
+
319
+ remove.byType(
320
+ type: 'object' | 'array' | 'number' | 'string' | 'boolean' | 'function' | 'undefined'
321
+ ): this
322
+ ```
239
323
240
324
#### replace: PublicArrayReplacer (read-only)
241
325
@@ -247,7 +331,6 @@ getAndRemove.byType(
247
331
### Methods
248
332
249
333
```
250
-
251
334
asString(glue = ', '): string
252
335
// Does same thing as Array.join()
253
336
0 commit comments