Filter items from an array or arguments that match the specified javascript native type. Uses a very fast filter function.
Install with npm
npm i filter-type --savevar filter = require('filter-type');
filter(array, type);Params
arrayThe array to filtertypeNative JavaScript type to filter by (e.g.string,functionetc)
Examples
var arr = [1, 'a', {aaa: 'bbb'}, 3, 'b', 'c', 7, ['foo', 'bar'], function one(){}];
filter(arr, 'object');
//=> [{aaa: 'bbb'}]
filter(arr, 'array');
//=> [['foo', 'bar']]
filter(arr, 'number');
//=> [1, 3, 7]
filter(arr, 'string');
//=> ['a', 'b', 'c']
filter(arr, 'function');
//=> [function one(){}]- arr-filter: Faster alternative to javascript's native filter method.
- arr-map: Faster, node.js focused alternative to JavaScript's native array map.
- arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
- filter-types: Filter items from an array or arguments that match the specified javascript native type or… more
Install dev dependencies:
npm i -d && npm testPull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 02, 2015.[assemble]: http://assemble.io [template]: https://github.com/jonschlinkert/template [verb]: https://github.com/assemble/verb