A helper for creating nicely chained Javascript interfaces with promises