extensible-promisify

Transform extensible objects APIs to conform with the Promises/A+ spec

Usage no npm install needed!

<script type="module">
  import extensiblePromisify from 'https://cdn.skypack.dev/extensible-promisify';
</script>

README

extensible-promisify

Transform extensible objects APIs to conform with the Promises/A+ spec

Build Status
browser support

Installation

npm install --save extensible-promisify

Usage

A simple way to use is declare methods with the 'promisify' flag:

var extensible = require('extensible');
var extensiblePromisify = require('extensible-promisify');

var obj = extensible();
obj.addMethod('method1', 'arg1, arg2, cb', {promisify: true});
obj.addMethod('method2', 'arg1, arg2');
obj.use(extensiblePromisify);
// method1 now has a promise/a+ API while method2 is unaffected

Another way is provide a predicate to select which methods need to be promisified:

obj.use(extensiblePromisify, function(method) {
  return method.args[method.args.length - 1] === 'cb';
});