Skip to content

burawi/echasync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Prefer Videos ?

Watch this video to see an example

Installation

npm install echasync

Usage

This is wrote following the OADS Standards.

echasync.do([loopedArray],operation(next(),element,#index,[loopedArray]),callback())

Loops through an array asynchronously.

  • [loopedArray]: The array you want loop through.
  • operation(): The function you want to run for each element in the array.
    • next(): When you call to this function, you move to the next element.
    • element: The value of the element being handled.
    • #index: The index of the element being handled.
    • [loopedArray]: The array you are looping through.
  • callback(): The function to run when all the elements are been handled.

Eg:

var echasync = require('echasync');
var files = ['1.txt','2.txt','3.txt','4.txt','5.txt'];
var contents = [];
echasync.do(files,function (next,filename,index,files) {
    fs.readFile(filename,function(err,data){
        if(!err) {
            contents.push(data);
            next();
        }
    });
},function () {
    console.log(contents);
});

About

nodejs asyncronous foreach method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published