Package Exports
- promise-with-status
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (promise-with-status) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
promise-with-status

A promise exports
statusandvalue(orreason).
Install
$ npm i -S promise-with-statusUsage
const withStatus = require('promise-with-status')(Promise)
// or: const withStatus = require('promise-with-status')(require('your-favorite-promise-lib'))
const promise = withStatus(Promise.resolve(123))
console.log(promise.status) //=> Symbol(pending)
promise.then(() => console.log(promise.status)) //=> Symbol(fullfilled)
promise.then(() => console.log(promise.value)) //=> 123
const error = withStatus(Promise.reject(new Error('wow')))
error.then(() => console.log(promise.status)) //=> Symbol(rejected)
error.then(() => console.log(promise.reason)) //=> Error: wowAPI
require('with-promise-status')(Promise)
Returns withStatus(promise) function.
Promise
Type: Function
Your favorite Promise implementation
withStatus(promise)
Returns new promise having status and other properties.
promise
Type: Promise
A promise, howver it will be not modified.
promise.status
withStatus.pending, withStatus.fullfilled or withStatus.rejected
promise.value
If promise.status === withStatus.fullfilled is true, it is promise's fullfilled value.
promise.reason
If promise.status === withStatus.rejected is true, it is promise's rejected reason.
withStatus.pending, withStatus.fullfilled, withStatus.rejected
Exported symbols which means each statuses.
License
MIT and 🍣 © TSUYUSATO "MakeNowJust" Kitsune <make.just.on@gmail.com> 2016