Filter items from an array or arguments that match the specified javascript native type or types. Uses a very fast filter function.
Install with npm
npm i filter-types --save
var filter = require('filter-types');
filter(array, types);
Params
array
The array to filtertypes
Native JavaScript type or types to filter
Examples
var arr = [1, 'a', {aaa: 'bbb'}, 3, 'b', 'c', 7, ['foo', 'bar'], function one(){}];
filter(arr, 'object');
//=> [{aaa: 'bbb'}]
filter(arr, ['object', 'array']);
//=> [{aaa: 'bbb'}, ['foo', 'bar']]
filter(arr, ['string', 'number']);
//=> [1, 'a', 3, 'b', 'c', 7]
- 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-type: Filter an array or arguments by JavaScript native type (e.g. functions, strings, etc).
Install dev dependencies:
npm i -d && npm test
Pull 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