npm.io
2.0.5 • Published 7 years ago

@writetome51/array-get-and-remove-filtered-results

Licence
MIT
Version
2.0.5
Deps
5
Size
12 kB
Vulns
0
Weekly
0
Stars
1
DeprecatedThis package is deprecated

This function removes array items if they pass a test-function, and
returns an array of IValueIndexPairs.
A IValueIndexPair is this object: {value: any, index: integer}

getAndRemoveFilteredResults(testFunction, array): IValueIndexPair[]

testFunction = function(item, index?, array?): boolean

Example:

let arr = [1,2,3,4,5,6,7,8,9,10];

let removed = getAndRemoveFilteredResults((item) => item < 3, arr);

removed is now [ {value:1, index:0}, {value:2, index:1} ]

Keywords