Skip to content

Commit

Permalink
Readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
eliamaino-fp committed May 18, 2018
1 parent 86ff396 commit 82b3ffb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# forcible-promise
A es6 Promise wrapper which allows you to force either resolve or reject
A JavaScript es6 Promise wrapper which allows you to force either resolve or reject.

## Install
`forcible-promise` is provided as an npm package, so you can easily install it with
```bash
npm install forcible-promise
```

## Usage
```javascript
import { forciblePromise } from 'forcible-promise'

const originalPromise = new Promise((resolve, reject) => {
// Logic which resolves or rejects
});

// Get a forcible version of the original promise
const forcible = forciblePromise(originalPromise);

forcible
.then(data => console.log(data))
.catch(err => console.log(err))
.finally(() => console.log('done'))

// Force the resolving of the forcible by calling forceResolve
// This will trigger the then of the promise
forcible.forceResolve(data)

// Force the rejection of the forcible by calling forceReject
// This will trigger the catch of the promise
forcible.forceReject(err)
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "forcible-promise",
"version": "1.0.0",
"description": "A es6 Promise wrapper which allows you to force either resolve or reject",
"main": "forcible-promise.js",
"main": "src/forcible-promise.js",
"scripts": {
"test": "jasmine"
},
Expand Down

0 comments on commit 82b3ffb

Please sign in to comment.