rho-cc-promise
Create rho-contracts for Promises.
Usage
Use with @rho-contracts/rho-contracts
:
"dependencies": "@rho-contracts/rho-contracts": "^3.0.0"
Use this module to create contracts for promises. The returned contracts check
the values of resolve
and optionally reject
, propagating contract errors
through reject
.
Calling withError
on the returned contract changes the type of the error
argument to the contract specified.
The main entry point of this module is a mixin, which extends c.fn
and c.fun
to return contracts with returnsPromise
methods.
const c = const cc = {} ccinfo = cobject data: cany ccgetInfo = c // A function which returns a promise which resolves with no value.ccdoSomething = c // A function which returns a promise which rejects with a custom error type.cccustomError = c ccdoSomething = c
It's compatible with most promise implementations, including ES6 Promise and implementations which adhere to A+.
Installation
npm install rho-contracts-fork rho-cc-promise
Contribute
Pull requests welcome!
License
The project is dually licensed under the Mozilla Public License Version 2.0, and the MIT license. You may use either one, at your option.