Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 28 days 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 1 year ago)
- Default Branch: master
- Last Pushed: 2023-03-04T10:39:58.000Z (over 1 year ago)
- Last Synced: 2024-05-01T18:54:22.502Z (7 months ago)
- Topics: async, await, browser, finally, future, javascript, promise, typescript, unit-test
- Language: TypeScript
- Homepage:
- Size: 125 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)
}
```