@brainsights/promise-task
Advanced tools
Comparing version 1.0.1 to 2.0.0
46
index.js
@@ -143,47 +143,1 @@ const EventEmitter = require("events") | ||
module.exports = Task; | ||
(async () => { | ||
try { | ||
let task1 = new Task(async (context) => { | ||
let progress = 0; | ||
let timer; | ||
timer = setInterval(() => { | ||
progress += 1; | ||
if(progress >= 100) { | ||
clearTimeout(timer); | ||
context.progress(100); | ||
context.resolve(); | ||
} else { | ||
context.progress(progress); | ||
} | ||
}, 10); | ||
context.onCancel = () => { | ||
clearTimeout(timer); | ||
}; | ||
}); | ||
let task2 = new Task(async (context) => { | ||
let progress = 0; | ||
let timer; | ||
timer = setInterval(() => { | ||
progress += 1; | ||
if(progress >= 100) { | ||
clearTimeout(timer); | ||
context.progress(100); | ||
context.resolve(); | ||
} else { | ||
context.progress(progress); | ||
} | ||
}, 100); | ||
context.onCancel = () => { | ||
clearTimeout(timer); | ||
}; | ||
}); | ||
let batch = Task.series([task1, task2]); | ||
batch.on("progress", (progress) => console.log(progress)); | ||
await batch.run(); | ||
} catch(e) { | ||
console.trace(e); | ||
} | ||
})(); |
{ | ||
"name": "@brainsights/promise-task", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Lazy promises with support for cancellation and progress events", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4956
125