
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@brainsights/promise-task
Advanced tools
Lazy promises with progress and cancelation.
npm install promise-task
Use a task anywhere you would use a promise, with a few minor changes.
const Task = require("promise-task");
let task = new Task((context) => {
let progress = 0;
let timer;
timer = setInterval(() => {
progress += 1;
if(progress >= 100) {
clearTimeout(timer);
context.progress(100);
context.resolve(true);
} else {
context.progress(progress);
}
}, 100);
context.onCancel = () => {
clearTimeout(timer);
};
});
task.on("progress", (progress) => console.log(progress));
await task.run();
Create a new task by new Task(executor)
.
executor (Function)
accepts a single argument, context
.Invoke this to begin executing the task. Returns a Promise
that is resolved or rejected when the task completes.
Returns the current progress as number.
Cancels execution and rejects the associated promise.
Returns true if the task is canceled, false otherwise.
Creates a copy of a task instance.
Returns a new Task
that wraps one or more tasks that are executed one-at-a-time.
tasks (Array)
: A list of tasks to execute in series when run()
is invoked.
Task property that contains the last Error
if there is one, or null.
Invoke this from the executor
to resolve the associated promise.
result (Any)
: The successful result of the completed task.Invoke this from the exectutor
to reject the associated promise.
error (Error)
: An error explaining why the task failed.Invoke this from the executor
to update the task progress.
value
: A number between 0 and 100 (inclusive).Set this property to the callback that should be invoked if the task is canceled. This property is only writable, and cannot be read.
callback (Function)
: A callback function invoked when Task.cancel()
is called.FAQs
Lazy promises with support for cancellation and progress events
We found that @brainsights/promise-task demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.