0.1.2 • Published 6 years ago
array-filterto v0.1.2
array-filterto
NOTE: array-filterto was renamed to @extra-array/filter.
Filter values from array that pass the test, like Array.filter().
const filterTo = require('array-filterto');
// filterTo(<array>, <test function>, [this], [begin=0], [end], [target=[]], [at])
// - <test function>(<value>, <index>, <array>)
filterTo(['l', 'i', 'v', 'e'], (v) => v>'e');
// ['l', 'i', 'v']
filterTo(['l', 'i', 'v', 'e'], (v, i, arr) => v>'e', null, 1);
// ['i', 'v']
filterTo(['l', 'i', 'v', 'e'], (v, i, arr) => v>'e', null, 1, 3);
// ['i', 'v']
filterTo(['l', 'i', 'v', 'e'], (v, i, arr) => v>'e', null, 1, 3, ['s', 'h']);
// ['s', 'h', 'i', 'v']
filterTo(['l', 'i', 'v', 'e'], (v, i, arr) => v>'e', null, 1, 3, ['s', 'h'], 1);
// ['s', 'i', 'v']