-
-
Notifications
You must be signed in to change notification settings - Fork 71
feature: all bind-all when passed an object #48
Copy link
Copy link
Closed
Description
pify has a nice feature where you can promisify an obj's methods
example from readme:
// Promisify all methods in a module
pify(fs).readFile('package.json', 'utf8').then(data => {
console.log(JSON.parse(data).name);
//=> 'pify'
});however this doesnt work when the child methods expect a reference to the owning object
example from my experience:
const Client = require('coinbase').Client
const pify = require('pify')
const client = pify(new Client({}))
const accounts = await client.getAccounts(null) // fails due to unset `this` referencework around - use bind-all:
const Client = require('coinbase').Client
const pify = require('pify')
const bindAll = require('bind-all')
const client = pify(bindAll(new Client({})))
const accounts = await client.getAccounts(null)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels