New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2.0 to 2.2.1

36

index.js

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

{
constructor(task, resolve, reject)
constructor(task, resolve, reject, options={})
{

@@ -19,2 +19,3 @@ __.set(this, {

reject: reject,
options: options,
});

@@ -53,7 +54,13 @@ }

__.get(task).onCancel = () => {
if(cb)
if(cb && _.isFunction(cb)) {
cb.call(this);
}
this.reject(new Error("canceled"));
}
}
get options()
{
return __.get(this).options;
}
}

@@ -77,3 +84,3 @@

executor(context)
async executor(context)
{

@@ -83,3 +90,3 @@ __.get(this).executor(context);

run()
run(options)
{

@@ -92,11 +99,20 @@ if(!__.get(this).promise) {

let promise = new Promise((resolve, reject) => {
let context = new Context(this, resolve, reject);
this.executor(context);
let promise = new Promise(async (resolve, reject) => {
let context = new Context(this, resolve, reject, options);
await this.executor(context);
});
__.get(this).promise = promise;
return promise;
} else {
throw new Error("task is already running");
}
}
return __.get(this).promise;
get promise()
{
if(!__.get(this).promise)
throw new Error("task is not started");
else
return __.get(this).promise;
}

@@ -149,7 +165,7 @@

canceled = true;
task.cancel
task.cancel();
};
try {
results[i] = await task.run();
results[i] = await task.run(context.options);
} catch(e) {

@@ -156,0 +172,0 @@ return context.reject(e);

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

@@ -17,4 +17,4 @@ "main": "index.js",

"@brainsights/uuid": "1.1.0",
"lodash": "^4.17.5"
"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