src/util.js
function promisify(func) {
  return function promisified() {
    var args = Array.prototype.slice.call(arguments);
    var context = this;

    return new Promise(function(resolve, reject) {
      try {
        func.apply(context, args.concat(function(err, data) {
          if (err) {
            return reject(err);
          }

          resolve(data);
        }));
      } catch(err) {
        reject(err);
      }
    });
  };
}
function promisify(func) {
  return function promisified() {
    var args = Array.prototype.slice.call(arguments);
    var context = this;

    return new Promise(function(resolve, reject) {
      try {
        func.apply(context, args.concat(function(err, data) {
          if (err) {
            return reject(err);
          }

          resolve(data);
        }));
      } catch(err) {
        reject(err);
      }
    });
  };
}
function promisify ( func ) { return function promisified ( ) { var args = Array . prototype . slice . call ( arguments ) ; var context = this ; return new Promise ( function ( resolve , reject ) { try { func . apply ( context , args . concat ( function ( err , data ) { if ( err ) { return reject ( err ) ; } resolve ( data ) ; } ) ) ; } catch ( err ) { reject ( err ) ; } } ) ; } ; }
Transforms a callback-based function flow to a promise-based flow
Transforms a callback - based function flow to a promise - based flow