filter-types
Filter items from an array or arguments that match the specified javascript native type or types. Uses a very fast filter function.
npm
Install withnpm i filter-types --save
Usage
var filter = require('filter-types');
filter(array, types);
Params
-
array
The array to filter -
types
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]
Related projects
- 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).
Running tests
Install dev dependencies:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2014-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