code: function promiseOrCallback (callback, executor) {
      var promise = new Promise(executor);
  
      // no callback: do not attach
      if (typeof callback !== 'function') {
          return promise;
      }
  
      return promise.then(function (value) {
          setImmediate(function () {
              callback(null, value);
          });
          return value;
      }, function (error) {
          setImmediate(function () {
              callback(error);
          });
          throw error;
      });
  }
docs: Build a promise, with an optional node-style callback attached