0.1.3 • Published 8 years ago

echasync v0.1.3

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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);
});
0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

9 years ago

0.0.1

9 years ago