Excerpted from an answer to this question.

  1. Every function that does something asynchronous must return a promise.
  2. Create an immediate wrapper for every function that doesn't do something asynchronous.
  3. Everything that does something with an asynchronous result goes into a .then callback.