Package Exports
- promise-to-call
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (promise-to-call) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Promise to Call

Replace callbacks with promises.
Targets to call can be methods of objects (useful "this") or functions (useless "this").
Installation
$ npm install promise-to-call
Usage
const promiseTo = require('promise-to-call');
promiseTo.$callMethod(someObject, 'someMethod', 2, 3)
.then((data) => { ... })
.catch((err) => { ... });
promiseTo.$callFunction(someFunction, 2, 3)
.then((data) => { ... })
.catch((err) => { ... });
Example
const AWS = require('aws-sdk');
const promiseTo = require('promise-to-call');
function whoAmI() {
const stsService = new AWS.STS({ region: 'us-east-1' });
return promiseTo.$callMethod(stsService, 'getCallerIdentity', {})
.then((data) => {
return data.Account;
})
.catch(console.error);
}
whoAmI().then(console.log); // -> 123456789012
Options
This module uses Promise
by default. If you want to use some other class, do this:
promiseTo.usePromiseClass(SomePromiseClass);
promiseTo.usePromiseClass(); // back to using Promise
Tests
$ npm test