Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sevenwestmedia-labs/promise-completion-source
Creates a promise producer which controls the completion/rejection of the promise available through the .promise key.
https://github.com/sevenwestmedia-labs/promise-completion-source
promise
Last synced: 7 days ago
JSON representation
Creates a promise producer which controls the completion/rejection of the promise available through the .promise key.
- Host: GitHub
- URL: https://github.com/sevenwestmedia-labs/promise-completion-source
- Owner: sevenwestmedia-labs
- License: mit
- Created: 2019-01-01T04:33:24.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T02:13:55.000Z (about 2 years ago)
- Last Synced: 2023-03-02T12:16:15.846Z (almost 2 years ago)
- Topics: promise
- Language: TypeScript
- Homepage:
- Size: 2 MB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Promise completion source
[![Build Status](https://travis-ci.com/sevenwestmedia-labs/promise-completion-source.svg?branch=master)](https://travis-ci.com/sevenwestmedia-labs/promise-completion-source)
[![NPM Package](https://img.shields.io/npm/v/promise-completion-source.svg)](https://www.npmjs.com/package/promise-completion-source) [![Greenkeeper badge](https://badges.greenkeeper.io/sevenwestmedia-labs/promise-completion-source.svg)](https://greenkeeper.io/)Creates a promise producer which controls the completion/rejection of the promise available through the .promise key.
## Example
```ts
import { PromiseCompletionSource } from 'promise-completion-source'const promiseCompletionSource = new PromiseCompletionSource()
// This is a promise which can be awaited or passed around as a future
const promise = promiseCompletionSource.promise// Then you can resolve/reject using the completion source
promiseCompletionSource.resolve(result)
// or
promiseCompletionSource.reject(new Error('Some error'))// You can also check completion
const isPromiseCompleted = promiseCompletionSource.completed
```