https://github.com/writetome51/array-remove-all-after
2 functions that remove all items that come after a certain value in the array
https://github.com/writetome51/array-remove-all-after
array-manipulations items javascript remove remove-elements typescript
Last synced: 3 months ago
JSON representation
2 functions that remove all items that come after a certain value in the array
- Host: GitHub
- URL: https://github.com/writetome51/array-remove-all-after
- Owner: writetome51
- License: mit
- Created: 2019-03-01T03:40:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-01T03:51:37.000Z (about 6 years ago)
- Last Synced: 2025-01-02T07:26:10.134Z (5 months ago)
- Topics: array-manipulations, items, javascript, remove, remove-elements, typescript
- Language: TypeScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# removeAllAfterFirst(value, array): void
Removes everything after first instance of `value` in `array`.
# removeAllAfterLast(value, array): void
Removes everything after last instance of `value` in `array`.
For both, `value` cannot be an object. It can be an array.
Examples:
```
let arr = [5,10,15,20,10,50,60,70];
removeAllAfterFirst(10, arr);
// arr is now [5,10]let arr = [5,10,15,20,10,50,60,70];
removeAllAfterLast(10, arr);
// arr is now [5,10,15,20,10]
```## Installation
`npm i @writetome51/array-remove-all-after`## Loading
```
// if using TypeScript:
import {removeAllAfterFirst, removeAllAfterLast} from '@writetome51/array-remove-all-after';
// if using ES5 JavaScript:
var removeAllAfterFirst =
require('@writetome51/array-remove-all-after').removeAllAfterFirst;
var removeAllAfterLast =
require('@writetome51/array-remove-all-after').removeAllAfterLast;
```