Added resolve/reject methods to When to return a Promise<T>