public-promise

Promise that exposes resolve and reject publicly

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
public-promise
251.0.36 years ago6 years agoMinified + gzip package size for public-promise in KB

Readme

public-promise Build Status
Promise that exposes resolve and reject publicly
Installation
npm i --save public-promise
Usage
Create a "public" promise and resolve it
import PublicPromise from 'public-promise'

const promise = new PublicPromise()

promise.then((data) => console.log(data)) // { foo: 'foo' }

const data = { foo: 'foo' }
promise.resolve(data)

Create a "public" promise and reject it
import PublicPromise from 'public-promise'

const promise = new PublicPromise()

promise.catch((err) => console.log(err)) // [ Error: boom ]

const err = new Error('boom')
promise.reject(err)
License
MIT