2.0.0 • Published 8 years ago
queue5 v2.0.0
Queue5
A simple queue for javascript. Chinese document
Install
$ npm install queue5
Use
Simple:
const queue=require('Queue5');
const arr = [];
for (let i = 0; i < 100; i += 1) {
arr.push(1000 + i);
}
queue(arr, 10, (item, next) => {
setTimeout((val) => {
console.log(val);
next(); // Here is the condition that the queue can carry out
}, item, item);
});
Professional:
const queue=require('Queue5');
const arr = [];
for (let i = 0; i < 100; i += 1) {
arr.push(1000 + i);
}
async function test(args) {
const result = await queue(args, 20, (item, next) => {
setTimeout(() => {
next('next'); // Pass data through next()
}, item);
});
console.log(result); //The final result is an Array
}
test(arr);
License
The MIT License。Please enjoy free source。