Promise.resolve() and jQuery deferreds

# Axel Rauschmayer (11 years ago)

AFAICT, Promise.resolve() is enough to convert jQuery deferreds to the ES6 API. Correct?

# C. Scott Ananian (11 years ago)

On Fri, Oct 3, 2014 at 9:21 AM, Axel Rauschmayer <axel at rauschma.de> wrote:

AFAICT, Promise.resolve() is enough to convert jQuery deferreds to the ES6 API. Correct?

AFAIK Promise.resolve() should be enough to turn any thenable into a promise.

And when you subclass, SubPromise.resolve(p) should be enough to turn any thenable or promise of a different subclass into your subclass.

I have considered rewriting my prfun library of Promise utilities so that it creates a subclass of Promise rather than adding methods to the global prototype. This would require var Promise = require('prfun') would return the subclass, and you'd need to do Promise.resolve(p) whenever you got a promise (or thenable) from "outside" your API in order to ensure that the result had the prfun methods.

(If I'm misunderstanding Promise.resolve, let me know!)