Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chpio/babel-plugin-transform-promise-to-bluebird
https://github.com/chpio/babel-plugin-transform-promise-to-bluebird
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/chpio/babel-plugin-transform-promise-to-bluebird
- Owner: chpio
- License: mit
- Created: 2016-07-04T06:17:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-23T07:13:20.000Z (over 5 years ago)
- Last Synced: 2024-11-03T04:06:36.456Z (3 days ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 41
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# babel-plugin-transform-promise-to-bluebird
This plugin transforms `Promise` to `bluebird`.
## Example
```javascript
export default function main() {
const taskA = getResultAsync(1337);
const taskB = new Promise((resolve, reject) =>
nodeCallbackFunc(42, (err, res) => err ? reject(err) : resolve(res))
);
return Promise.all([taskA, taskB]).then(([resA, resB]) => resA + resB);
}
```
Gets converted to:
```javascript
import {all, default as Promise} from 'bluebird';export default function main() {
const taskA = getResultAsync(1337);
const taskB = new Promise((resolve, reject) =>
nodeCallbackFunc(42, (err, res) => err ? reject(err) : resolve(res))
);
return all([taskA, taskB]).then(([resA, resB]) => resA + resB);
}
```## Usage
1. Install *bluebird*: `npm install --save bluebird`
2. Install the *promise-to-bluebird* plugin: `npm install --save-dev babel-plugin-transform-promise-to-bluebird`
3. Add *transform-promise-to-bluebird* to your *.babelrc* file:
```json
{
"plugins": ["transform-promise-to-bluebird"]
}
```
If you'r using the *transform-runtime* plugin add *transform-promise-to-bluebird* before
*transform-runtime*:
```json
{
"plugins": [
"transform-promise-to-bluebird",
"transform-runtime"
]
}
```