Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brainsights/promise-task

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainsights/promise-task - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

30

index.js

@@ -42,3 +42,3 @@ const EventEmitter = require("events")

if(progress !== value) {
__.get(task).progress = value;
__.get(task).progress = toPercent(value);
task.emit("progress", value);

@@ -52,3 +52,4 @@ }

__.get(task).onCancel = () => {
cb.call(this);
if(cb)
cb.call(this);
this.reject(new Error("canceled"));

@@ -106,3 +107,3 @@ }

{
if(__.get(this).isRunning) {
if(__.get(this).isRunning) {
__.get(this).onCancel.call(this);

@@ -125,3 +126,3 @@ __.get(this).isCanceled = true;

{
return new this.constructor(__.get(this).executor);
return new Task(__.get(this).executor);
}

@@ -132,10 +133,21 @@

let batch = new Task(async (context) => {
for(let task of tasks) {
let results = [];
let canceled = false;
for(let i = 0; i < tasks.length && !canceled; ++ i) {
let task = tasks[i];
task.on("progress", () => {
context.progress(toPercent(
_.sum(_.map(tasks, (item) => item.progress()))/tasks.length
));
context.progress(_.sum(_.map(tasks, (item) => item.progress()))/tasks.length);
});
await task.run();
context.onCancel= () => {
canceled = true;
task.cancel
};
try {
results[i] = await task.run();
} catch(e) {
return context.reject(e);
}
}
context.resolve(results);
});

@@ -142,0 +154,0 @@

{
"name": "@brainsights/promise-task",
"version": "2.0.0",
"version": "2.1.0",
"description": "Lazy promises with support for cancellation and progress events",

@@ -16,4 +16,5 @@ "main": "index.js",

"dependencies": {
"@brainsights/uuid": "1.1.0",
"lodash": "^4.17.5"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc