es6-promise
A polyfill for ES6-style Promises
A polyfill that adds Promise support to older browsers and environments that do not have it built in, so you can write modern async JavaScript that still works in Internet Explorer and other legacy targets.
es6-promise is a polyfill for the Promise feature in modern JavaScript. A polyfill is a piece of code that adds a feature to older environments that do not have it built in. Promises are a way of writing asynchronous code, meaning code that deals with tasks that take time, such as network requests, without blocking everything else while waiting. They let you describe what should happen when a task succeeds or fails, in a cleaner style than older callback patterns.
This library was particularly useful in the years when older browsers and older versions of Internet Explorer did not support Promises natively. Including it meant your code could use the standard Promise syntax and still work on those older environments. There are two main build variants: the standard one, where you load it and refer to it explicitly in your code, and the auto variant, which automatically replaces or adds the global Promise object if it is missing or not working correctly.
Installation works through npm or yarn, and you can also load it directly in a webpage via a CDN script tag. There are minified versions of both variants for production use. For Node.js you import it and refer to its Promise export, or call a polyfill method once at startup to patch the global environment for your whole application.
The README notes a quirk for very old Internet Explorer versions where the words catch and finally are reserved keywords that cause a syntax error when used as method names in dot notation. The workaround is to use bracket notation instead, though most code minifiers fix this automatically. The library is a focused subset of a larger library called rsvp.js and does not include the extra debugging and inspection features that the full library provides.
Where it fits
- Use modern Promise-based async code in a project that must still support old browsers like Internet Explorer 11.
- Patch the global Promise object automatically at app startup so all existing code in a Node.js app works without changes.
- Include a minified CDN build on a legacy webpage to enable async patterns without a build step.