Skip to content

isabella232/async-filter-each

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-filter-each

stable

async.filter() as a standalone module, in the interest of modularity and smaller bundle size.

Install

npm install async-filter-each --save

Example

var filter = require('async-filter-each')

filter(filenames, fs.exists, function (results) {
  // results are now filtered down to files which exist
  console.log(results)
})

Usage

filter(items, iterator, [callback])

Returns a new array of all the values in items which pass an async truth test. The callback for each iterator call only accepts a single argument of true or false; it does not accept an error argument first! This is in-line with the way node libraries work with truth tests like fs.exists. This operation is performed in parallel, but the results array will be in the same order as the original.

Arguments:

  • items
    An array to iterate over.
  • iterator(item, callback)
    A truth test to apply to each item in arr. The iterator is passed a callback(truthValue), which must be called with a boolean argument once it has completed.
  • callback(results)
    (optional) A callback which is called after all the iterator functions have finished.

License

MIT, see LICENSE.md for details.

About

async#filter() as a module

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%