@@ -272,6 +272,9 @@ getAndRemove.byType(
272
272
```
273
273
insert.at(index, values: any[]): PublicArrayInserter
274
274
// inserts values at index. index can be negative or positive.
275
+ // If positive, existing items beginning at that index will be pushed to the right to
276
+ // make room. If negative, existing items ending at that index will be pushed to the
277
+ // left to make room.
275
278
276
279
insert.middle(values: any[], offset = 0): PublicArrayInserter
277
280
// inserts values in middle of this.data .
@@ -573,6 +576,27 @@ arr.data = [item1, item2, item3, ...];
573
576
574
577
// changing the array content without breaking its memory reference:
575
578
arr.set( [item1, item2, item3, ...] );
579
+
580
+ // using .append() instead of .push():
581
+ arr.append(['goodbye']); // now the last item in arr.data is 'goodbye'
582
+
583
+ // using .prepend() instead of .unshift():
584
+ arr.prepend(['hello']); // now the first item in arr.data is 'hello'
585
+
586
+ // checking if array has a particular item:
587
+ arr.data = ['a', 'q', 'r', 'z', 'x'];
588
+ if (arr.has('q')) console.log('yes'); // --> 'yes'
589
+
590
+ // checking if array has exact sequence of adjacent items:
591
+ arr.data = [3,6,9,12,11,3,5,1];
592
+ if (arr.hasAdjacent([9,12,11,3])) console.log('yes'); // --> 'yes'
593
+
594
+ // removing any items that aren't numbers and putting the numbers in order:
595
+ arr.filter.byType('number');
596
+ arr.sort.numbersAscending();
597
+
598
+ // removing and returning dirty 4-letter words:
599
+ let dirtyWords = arr.getAndRemove.byTest((item) => isString(item) && item.length === 4);
576
600
```
577
601
578
602
## Performance
0 commit comments