![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@brainsights/promise-task
Advanced tools
Lazy promises with support for cancellation and progress events
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.