Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Node.js Callback Contract

#callback/errback contract

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
  4. Return value is ignored
  5. Must not throw / must pass resulting errors
  6. Must never be called more than once