Socket
Socket
Sign inDemoInstall

ee-async

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-async

simpler control flow for asynchronous operations


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

ee-async

simple control flow helpers

installation

npm install ee-async

build status

Build Status

usage

var async = require( "ee-async" );

each

execute a function on every item passed to the function using an array

async.each( [ items ], worker, [ worker ], [ .. ], callback );

the array of items can also be an array of array if the workers need more than one argument applied to them

async.each( [ "1.txt", "2.txt" ]
	, fs.readFile
	, function( data, next ){ 
		next( null, data.toString() ); 
	}
	, function( err, results ){
		log( results ); // [ "contents of 1.txt", "contents of 2.txt" ]
	} 
);

wait

execute functions in parallel

async.wait( function( complete ){ 
		complete( 1 ); 
	}, function( complete ){ 
		complete( 2 ); 
	}, function( err, results ){
		log( results ); // [ 1, 2 ]
	} 
);

chain

pass input through a chain of functions

async.chain("./test/1.txt"
	, fs.readFile
	, function( data, next ){ 
		next( null, data.toString() ); 
	}
	, function( err, data ){
		log( data ); // "contents of 1.txt"
	} 
);

wait for several callbacks

var waiter = async.waiter(function(err) {
	// both load events were fired
});

someAsyncApi.on('load', waiter());
anotherApi.on('load', waiter());

Keywords

FAQs

Package last updated on 20 May 2014

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