Understanding promises in Node.js

Promises in node.js promised to do some work and then had separate callbacks that would be executed for success and failure as well as handling timeouts. Another way to think of promises in node.js was that they were emitters that could emit only two events: success and error.

The cool thing about promises is you can combine them into dependency chains (do Promise C only when Promise A and Promise B complete).

By removing them from the core node.js, it created possibility of building up modules with different implementations of promises that can sit on top of the core. Some of these are node-promise and futures.


Since this question still has many views (like mine) I wanted to point out that:

  1. node-promise looks rather dead to me (last commit was about 1 year ago) and contains nearly no tests.
  2. The futures module looks very bloated to me and is badly documented (and I think that the naming conventions are just bad)
  3. The best way to go seems to be the q framework, which is both active and well-documented.