@writetome51/array-remove-all-after
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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;

Package Sidebar

Install

npm i @writetome51/array-remove-all-after

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

9.44 kB

Total Files

10

Last publish

Collaborators

  • writetome51