Task - API
A task that can be resolved or rejected in the future..
Installation
- npm
- yarn
- pnpm
npm is the default package manager for Node.js, and to where tscommon is published.
Your project is using npm if it has a
Run the following command in your terminal:
Your project is using npm if it has a
package-lock.json
file in its root folder.Run the following command in your terminal:
terminal
npm install @tscommon/task
Usage
import { Task } from '@tscommon/task';
const task = new Task<number, number>(2);
setTimeout(() => {
task.resolve(task.input ** 2); // Resolve the task with the square of the input
});
task.then(console.log); // 4