Implements promises

Somewhat hastily written promises implementation using [when](https://github.com/cujojs/when).