1.0.5 • Published 5 years ago

@writetome51/array-get-indexes-intermediate v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

These are array-handling functions that return indexes of items in the array.

Returns all indexes of value in array:

getIndexesOf(value, array); // value cannot be object.

Self-explanatory:

getLastIndexOf(value, array); // value cannot be object.

This returns all indexes of array items that pass the testFunction:

getIndexesThatPass(testFunction, array)

testFunction = function(currentValue [, currentIndex , theArray]){ ... } // must return boolean.

Example:

let arr = 'a', 'boy', 'is', 'playing', 'in', 'the', 'street';

let stringsLongerThanThree = getIndexesThatPass((value) => value.length > 3, arr);

stringsLongerThanThree is now 3, 6