promise-stream-queue
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,0 +0,0 @@ function Item(id,pr,timeout) { |
49
main.js
@@ -90,49 +90,2 @@ const | ||
if(!module.parent) { | ||
const readline = require('readline'); | ||
var stream = new Stream(5000); | ||
var nums = []; | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
if(process.argv[2]=="sync") { | ||
stream.forEachSync((err,data,errcatch,next)=>{ | ||
if(errcatch) console.log("RESULT => Catch\t",err); | ||
else if(err) console.log("RESULT => Reject\t",err); | ||
else console.log("RESULT => Resolve\t",data); | ||
rl.question('Next? <yes> / no : ', (answer) => { | ||
if(!answer||answer=="next") next(); | ||
else process.exit(0); | ||
}); | ||
}); | ||
} | ||
else { | ||
stream.forEach((err,data,errcatch)=>{ | ||
if(errcatch) console.log("RESULT => Catch\t",err); | ||
else if(err) console.log("RESULT => Reject\t",err); | ||
else console.log("RESULT => Resolve\t",data); | ||
}); | ||
} | ||
for(var i=0;i<100;i++) nums.push(i); | ||
nums.forEach(i=>{ | ||
stream.push(new Promise((resolve,reject)=>{ | ||
var rnd = Math.random(); | ||
var to = Math.floor(Math.random()*10000); | ||
var data = "PR => "+i+", "+to; | ||
console.log(data); | ||
setTimeout(()=>{ | ||
if(rnd<=0.5) {resolve(data);} | ||
else {reject(data);} | ||
},to); | ||
})); | ||
}); | ||
} | ||
else { | ||
module.exports = Stream; | ||
} | ||
module.exports = Stream; |
{ | ||
"name": "promise-stream-queue", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Promise Stream. Queue promises and retrieve the resolved/rejected ones in the inserted order", | ||
@@ -5,0 +5,0 @@ "author": "David Gómez Matarrodona <solzimer@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
12409
9
206
1
132