implementation of the promise spec: http://promises-aplus.github.io/promises-spec/