fast-filter

1.0.4 • Public • Published

fast-filter

A replacement for the native [].filter method that performs 5-10 times faster in most environments.

Install

npm install fast-filter

Basic usage

var fastFilter = require('fast-filter');
 
fastFilter([1,2,3,4,5,6], function(val) { return val % 2; }); // [1,3,5]

"Installing" on the Array.prototype

You can add fastFilter to the native Array.prototype for convienience.

require('fast-filter').install();
 
[1,2,3,4,5,6].fastFilter(function(val) { return val % 2; }); // [1,3,5]

Or provide an alias:

require('fast-filter').install('select');
 
[1,2,3,4,5,6].select(function(val) { return val % 2; }); // [1,3,5]

Replacing the native filter method

You can replace the native Array.prototype.filter method, but keep in mind that this will modify the filter method for all code in this instance including any required modules and may result in unexpected behavior.

require('fast-filter').install('filter');
 
[1,2,3,4,5,6].filter(function(val) { return val % 2; }); // [1,3,5]

/fast-filter/

    Package Sidebar

    Install

    npm i fast-filter

    Weekly Downloads

    44

    Version

    1.0.4

    License

    none

    Last publish

    Collaborators

    • prestaul