Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bhallstein/promise-pls
Initialize a promise
https://github.com/bhallstein/promise-pls
Last synced: about 2 months ago
JSON representation
Initialize a promise
- Host: GitHub
- URL: https://github.com/bhallstein/promise-pls
- Owner: bhallstein
- Created: 2018-01-18T11:12:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-18T11:33:18.000Z (almost 7 years ago)
- Last Synced: 2024-09-22T00:50:59.351Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# promise-pls.js
Return an initialised promise, along with its resolve & reject methods.
## Install:
`npm i promise-pls --save`
## Usage:
```js
import promise_pls from 'promise-pls';function do_something() {
let { p, y, n } = promise_pls();function cb(error) {
if (error) {
n(error);
}
else {
y();
}
}run_task(cb);
return p;
}do_something()
.then(function() {
console.log('done!');
})
.catch(functoin(error) {
console.log('error:', error);
});
```## Without promise-pls:
```js
let [y, n];
let p = new Promise(function(_y, _n) {
[y, n] = [_y, _n];
});
```