Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filter-async

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-async

![https://travis-ci.org/sorribas/filter-async.svg?branch=master](https://travis-ci.org/sorribas/filter-async.svg?branch=master)

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

filter-async

https://travis-ci.org/sorribas/filter-async.svg?branch=master

Filter the elements of an array with an asynchronous predicate.

Usage

var filter = require('filter-async');
var fs = require('fs');

var isFile = function(file, callback) {
  fs.stat(file, function(err, stat) {
    if (err) return callback(err);
    cb(null, stat.isFile());
  });
};

filter(['some-file', 'some-other-file', 'some-directory'], isFile, function(err, files) {
  if (err) return console.log(err);
  console.log(files); // should print ['some-file, 'some-other-file'']
});

By default all the async predicates are run in a sequential manner, which means that elements of the array are processed one at a time. If you want to process them in parallel you can use the filter.parallel function. It has the same interface as the filter function.

The filter function is also aliased to filter.sequential.

License

MIT

FAQs

Package last updated on 07 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc