JSPM

  • Created
  • Published
  • Downloads 158
  • Score
    100M100P100Q72765F
  • License MIT

Easy sync loop processing for Node.js

Package Exports

  • easy-loop

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (easy-loop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

easy-loop

쉬운 동기식 반복 처리 (easy sync loop processing)

Arguments

1) Array or Object 		- require
2) process function 	- require
3) callback function 	- option

Examples

## Case 1 ##

var loop = require('easy-loop');

var arr = [1,2,3,4,5];

// available function name => 'for' or 'while' or 'loop'
loop.for(arr, function(i, value, next){	
    console.log(i, "=>", value);
    next();		//require
}, function(err){
    console.log("end");
});


## Result ##
0 '=>' 1
1 '=>' 2
2 '=>' 3
3 '=>' 4
4 '=>' 5
end




## Case 2  ##

var arr = [1,2,3,4,5];

// available function name => 'for' or 'while' or 'loop'
loop.while(arr, function(i, value, next){	
    console.log(i, "=>", value);
    if(i === 2)	next("error");
    else 		next();
}, function(err){
    console.log("end");
});


## Result ##
0 '=>' 1
1 '=>' 2
2 '=>' 3
end




## Case 3 ##

var obj = {a:1, b:2, c:3, d:4, e:5};

// available function name => 'for' or 'while' or 'loop'
loop.loop(arr, function(key, value, next){	
    console.log(key, "=>", value);
    next();
}, function(err){
    console.log("end");
});


## Result ##
a => 1
b => 2
c => 3
d => 4
e => 5
end