code: 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);
        }
      });
    };
  }
docs: Transforms a callback-based function flow to a promise-based flow