https://github.com/hazae41/future
Just like a Promise but you can manually resolve or reject it
https://github.com/hazae41/future
async await browser finally future javascript promise typescript unit-test
Last synced: about 1 year ago
JSON representation
Just like a Promise but you can manually resolve or reject it
- Host: GitHub
- URL: https://github.com/hazae41/future
- Owner: hazae41
- Created: 2023-03-02T13:57:08.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-30T06:10:35.000Z (about 1 year ago)
- Last Synced: 2025-04-19T23:55:08.205Z (about 1 year ago)
- Topics: async, await, browser, finally, future, javascript, promise, typescript, unit-test
- Language: TypeScript
- Homepage:
- Size: 146 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
Just like a Promise but you can manually resolve or reject it
```bash
npm i @hazae41/future
```
[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/future)
## Features
### Current features
- 100% TypeScript and ESM
- No external dependencies
- Unit-tested
## Usage
```typescript
import { Future } from "@hazae41/future"
const future = new Future()
const t1 = setTimeout(() => future.resolve(), 1000)
const t2 = setTimeout(() => future.reject(), 2000)
try {
await future.promise
} finally {
clearTimeout(t1)
clearTimeout(t2)
}
```