I recently downloaded a library that uses ES6 Promises. Since I want to deploy to browsers which don't support Promises I also downloaded a polyfill.
Since I've got jQuery included anyway I thought about writing a polyfill for Promise which internally uses jQuery's Deferred.
I wrote this simple polyfill which is enough for my specific use case:
window.Promise = function(cb){
var promise = $.Deferred();
cb(promise.resolve, promise.reject);
return promise.promise();
};
The problem with this is that it doesn't cover the whole specification (thinks like Promise.all()
are missing).
Before I invest a lot of time into this I'd like to know if it is possible to write a full polyfill for Promise using jQuery's Deferred. Or are there some features which can't be replicated?