function create() {
  var state = 'pending';
  var values;
  var downstreamPromises = [];
  
  function isPromise(p) {
    return p && p.then instanceof Function;
  }

  function invoke(cb, args, promise) {
    try {
      var result = cb.apply(null, args);
      if (isPromise(result)) {
        result.then(promise.fulfill, promise.reject);
      } else {
        promise.fulfill(result);
      }
    } catch(e) {
      promise.reject(e);
    }
  }
  
  function fulfillDownstream(ds, args) {
    if(ds.onFulfilled) {
      invoke(ds.onFulfilled, args, ds.promise);
    } else {
      // Cascade to the next promise
      ds.promise.fulfill.apply(null, args);
    }
  }
  
  function fulfill(val) {
    if (state === 'pending') {
      state = 'fulfilled';
      values = arguments;
      downstreamPromises.forEach(function(ds) {
        fulfillDownstream(ds, values);
      });
    }
  }
  
  function rejectDownstream(ds, args) {
    if(ds.onRejected) {
      invoke(ds.onRejected, args, ds.promise);
    } else {
      // Cascade to the next promise
      ds.promise.reject.apply(null, args);
    }
  }
  
  function reject() {
    if (state === 'pending') {
      state = 'rejected';
      values = arguments;
      downstreamPromises.forEach(function(ds) {
        rejectDownstream(ds, values);
      });
    }
  }
  
  var cbPromise = function(err) {
    if (err) {
      reject(err);
    } else {
      fulfill.apply(null, Array.prototype.slice.call(arguments, 1));
    }
  }
  cbPromise.then = function(onFulfilled, onRejected) {
    onFulfilled = onFulfilled instanceof Function && onFulfilled;
    onRejected = onRejected instanceof Function && onRejected;
    var nextPromise = create();
    var ds = {onFulfilled: onFulfilled,
              onRejected: onRejected,
              promise: nextPromise}
    if (state === 'pending') {
      downstreamPromises.push(ds);
    } else if (state === 'fulfilled') {
      process.nextTick(fulfillDownstream.bind(null, ds, values));
    } else {
      process.nextTick(rejectDownstream.bind(null, ds, values));
    }
    return nextPromise;
  }
  cbPromise.fulfill = fulfill;
  cbPromise.reject = reject;
  return cbPromise;
}

module.exports.create = create;

// Return a new PFunc promise.
function create() {
  var state = 'pending';
  var values;
  var cascades = [];
  
  function isPromise(p) {
    return p && p.then instanceof Function;
  }

  // Invoke a resolution callback and cascade the result to the
  // downstream promise.
  function invokeCascadeCallback(cb, promise, args) {
    try {
      var result = cb.apply(null, args);
      if (isPromise(result)) {
        result.then(promise.fulfill, promise.reject);
      } else {
        promise.fulfill(result);
      }
    } catch(e) {
      promise.reject(e);
    }
  }
  
  // Return a function that will cascade a resolution value to the
  // downstream promise, routing it through the callback registered
  // with .then(), if present.
  function cascader(cb, passThrough, promise) {
    if (cb instanceof Function) {
      return invokeCascadeCallback.bind(null, cb, promise);
    } else {
      return function(args) { passThrough.apply(null, args); };
    }
  }
  
  // Resolve a pending promise to either 'fulfilled' or 'rejected' and
  // cascade the result to any downstream promises previously created
  // via .then().
  function resolve(newState /*, values* */) {
    if (state === 'pending') {
      state = newState;
      values = Array.prototype.slice.call(arguments, 1);
      cascades.forEach(function(cascade) {
        cascade[newState](values);
      });
    }
  }

  // The actual promise
  var promise = function(err /*, values* */) {
    if (err) {
      promise.reject(err);
    } else {
      var args = Array.prototype.slice.call(arguments, 1);
      promise.fulfill.apply(promise, args);
    }
  }
  promise.then = function(onFulfilled, onRejected) {
    var nextPromise = create();
    var cascade = {
      fulfilled: cascader(onFulfilled, nextPromise.fulfill, nextPromise),
      rejected: cascader(onRejected, nextPromise.reject, nextPromise)
    };

    if (state === 'pending') {
      cascades.push(cascade);
    } else {
      process.nextTick(cascade[state].bind(null, values));
    }
    return nextPromise;
  }
  promise.fulfill = resolve.bind(null, 'fulfilled');
  promise.reject = resolve.bind(null, 'rejected');

  return promise;
}

module.exports.create = create;

Simplify implementation with HOFs.