lib/tumblr.js
function promisifyRequest(requestMethod) {
    return function(apiPath, params, callback) {
        const promise = new Promise(function(resolve, reject) {
            requestMethod.call(this, apiPath, params, function(err, resp) {
                if (err) {
                    reject(err);
                } else {
                    resolve(resp);
                }
            });
        }.bind(this));

        if (callback) {
            promise
                .then(function(body) {
                    callback(null, body);
                })
                .catch(function(err) {
                    callback(err, null);
                });
        }

        return promise;
    };
}
function promisifyRequest(requestMethod) {
    return function(apiPath, params, callback) {
        const promise = new Promise(function(resolve, reject) {
            requestMethod.call(this, apiPath, params, function(err, resp) {
                if (err) {
                    reject(err);
                } else {
                    resolve(resp);
                }
            });
        }.bind(this));

        if (callback) {
            promise
                .then(function(body) {
                    callback(null, body);
                })
                .catch(function(err) {
                    callback(err, null);
                });
        }

        return promise;
    };
}
function promisifyRequest ( requestMethod ) { return function ( apiPath , params , callback ) { const promise = new Promise ( function ( resolve , reject ) { requestMethod . call ( this , apiPath , params , function ( err , resp ) { if ( err ) { reject ( err ) ; } else { resolve ( resp ) ; } } ) ; } . bind ( this ) ) ; if ( callback ) { promise . then ( function ( body ) { callback ( null , body ) ; } ) . catch ( function ( err ) { callback ( err , null ) ; } ) ; } return promise ; } ; }
Take a callback-based function and returns a Promise instead

@param  {Function} requestMethod - callback-based method to promisify

@return {Function} function that returns a Promise that resolves with the response body or
rejects with the error message

@private
Take a callback - based function and returns a Promise instead