https://github.com/writetome51/array-remove-all-before
2 functions that remove all items that come before a certain value in the array
https://github.com/writetome51/array-remove-all-before
array-manipulations items javascript remove remove-elements typescript
Last synced: 3 months ago
JSON representation
2 functions that remove all items that come before a certain value in the array
- Host: GitHub
- URL: https://github.com/writetome51/array-remove-all-before
- Owner: writetome51
- License: mit
- Created: 2019-03-01T04:04:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-01T04:04:55.000Z (about 6 years ago)
- Last Synced: 2025-02-13T04:11:18.345Z (3 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
# removeAllBeforeFirst(value, array):void
Removes everything before first instance of `value` in `array`.
# removeAllBeforeLast(value, array): void
Removes everything before last instance of `value` in `array`.
For both, the parameter `value` cannot be an object. It can be an array.
## Examples
```
let arr = [5, 10, 15, [20,22], 10, 50, [20,22], 60];
removeAllBeforeFirst([20,22], arr);
// arr is now [[20,22],10,50,[20,22],60]let arr = [5, 10, 15, [20,22], 10, 50, [20,22], 60];
removeAllBeforeLast([20,22], arr);
// arr is now [[20,22], 60]
```## Installation
`npm i @writetome51/array-remove-all-before`## Loading
```
// if using TypeScript:
import {removeAllBeforeFirst, removeAllBeforeLast} from '@writetome51/array-remove-all-before';
// if using ES5 JavaScript:
var removeAllBeforeFirst =
require('@writetome51/array-remove-all-before').removeAllBeforeFirst;
var removeAllBeforeLast =
require('@writetome51/array-remove-all-before').removeAllBeforeLast;
```