8000 GitHub - hazae41/future: Just like a Promise but you can manually resolve or reject it
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hazae41/future

Repository files navigation

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)
}

About

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

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published
0