Faster alternative to javascript's native filter method and array-filter.
array-filter is pretty popular, but it's tuned to be used in older browsers and it falls back on native .filter()
when available, which is much slower. See jsperf results. The functions used in the benchmarks are the top performers, reduced down from 10 or 11 additional functions.
Install with npm
npm i arr-filter --save
Install with bower
bower install arr-filter --save
npm test
var filter = require('arr-filter');
filter(['a', {a: 'b'}, 1, 'b', 2, {c: 'd'}, 'c'], function (ele) {
return typeof ele === 'string';
});
//=> ['a', 'b', 'c']
Jon Schlinkert
Other projects that I maintain:
- assemble
- verb
- less.js
- handlebars-helpers
- arr
- arr-diff
- array-last
- array-slice
- array-sum
- arrayify-compact
- compact-object
- delete
- for-in
- for-own
- has-any
- has-value
- is-number
- is-plain-object
- mixin-deep
- mixin-object
- object-length
- omit-empty
- reduce-object
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on October 01, 2014.