Skip to content

Refactored Promise for simplicity

Compare
Choose a tag to compare
@g105b g105b released this 21 Jan 12:09
· 17 commits to master since this release
148ab09

The original v1 release of this library was feature complete, but it was based on the complex design of CommonJS Promises. There were a number of issues that arose from the design limitations imposed by this decision, but the unit tests were already in place, so it was worth it to refactor the Promise class completely.

The new implementation has the same external functionality, but with two main improvements: 1) much better compatibility with Web API Promises; 2) much, much simpler.

The main point of this refactor is to move to a simpler queue-based system, rather than a recursive one. You can see the queue in action as the Promise's chain property, which will contain a reference to each of the new Chainable objects: ThenChain, CatchChain and FinallyChain.

Have fun!