array-filter-inplace
Remove non-matching elements from a dense array.
API
This module exports one function:
filter(array, test[, offset])
Test array
's items, starting at offset
(default = 0) by calling the
test
function with arguments (value, index, array)
.
If the test result isn't truthy, the item is removed¹ from the array.
Returns array
.
¹ "Remove" means it's either replaced with the next value that passes
the test, or cut off by setting array.length
.
Usage
from test.usage.js:
var filter = a b offset files = '.' '..' '.git' 'bin' 'README.md' 'package.json' ; { return s !== '.'; }a = files;b = ;;; a = files;offset = 2; // skip the first two itemsb = ;;; { return /[a-z]/ && !/[A-Z]/; }a = files;b = ;;;
License
ISC