@hazae41/future
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Just like a Promise but you can manually resolve or reject it

npm i @hazae41/future

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies
  • Unit-tested

Usage

import { Future } from "@hazae41/future"

const future = new Future<void>()

const t1 = setTimeout(() => future.resolve(), 1000)
const t2 = setTimeout(() => future.reject(), 2000)

try {
  await future.promise
} finally {
  clearTimeout(t1)
  clearTimeout(t2)
}

Package Sidebar

Install

npm i @hazae41/future

Weekly Downloads

57

Version

1.0.3

License

MIT

Unpacked Size

5.78 kB

Total Files

12

Last publish

Collaborators

  • hazae41