promises-aplus/promises-tests

Adapters needing `fulfilled(Value)` and `rejected(reason)` methods

Closed this issue · 4 comments

Couldn't these just be implimented from pending and tested that way, reducing the number of methods to be implemented in adapters:

exports.fulfilled = function (value) {
  let {promise, fulfill} = exports.pending();
  fulfill(value);
  return promise;
};

exports.rejected= function (value) {
  let {promise, reject} = exports.pending();
  reject(value);
  return promise;
};

(obviously you'd need to convert that to ES5 😄)

You're right, of course. The only objection is that promise libs might not get as much test coverage, if their create-fulfilled and create-rejected functions don't internally work by creating a pending first. I could go either way.

Can/should we provide default implementations for fulfilled and rejected for adapters that don't explicitly provide them? I.e. but still allow an adapter to provide them if it wants to?

Ooh, I kind of like that idea. Get better coverage if you want it, but not necessary.

I like that too