Skip to content

chpio/babel-plugin-transform-promise-to-bluebird

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-transform-promise-to-bluebird

This plugin transforms Promise to bluebird.

Example

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:

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:
{
	"plugins": ["transform-promise-to-bluebird"]
}

If you'r using the transform-runtime plugin add transform-promise-to-bluebird before transform-runtime:

{
	"plugins": [
		"transform-promise-to-bluebird",
		"transform-runtime"
	]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •