Skip to content
/ fan.js Public

A simple and easy-to-understand implementation of Promise/A+ spec for learning.

License

Notifications You must be signed in to change notification settings

dukeluo/fan.js

Repository files navigation

Promises/A+ logo

fan.js

fan.js is a implementation of the Promise/A+ spec written in ES5. It uses a simple and easy-to-understand style that closely matches every line of the spec. fan.js is a good example to reference when creating your own Promise and to help you learn the Promise/A+ spec.

Live Demo

Tasks for Creating Your Own Implementation of Promises/A+ Spec

  • Read the specification with use cases. Do it again if you have no idea how to begin.
  • Define the Promise class or constructor.
  • Make the Promises/A+ Compliance Test Suite works well with your code.
  • Define the then() method.
  • Implement chaining.
  • Handle errors.

Running the Test Suite

fan.js has passed all the tests in the Promises/A+ Compliance Test Suite.

To run all the tests, use the following command:

npm run test

The Promises/A+ Compliance Test Suite organizes tests by spec requirements. If you want to run the tests for a specific requirement, use a command like:

npm run test -- grep 2.1.2

Useful Resources