es6-promise
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The ES6-Promise is a lightweight programming library that serves as a polyfill of the ES6 Promise. It's designed to help JavaScript developers organize asynchronous code in an intuitive and efficient manner. It's particularly beneficial in environments where the Promise feature is missing or not properly functioning.
To use ES6-Promise, you'd first need to install it. For Node.js, this can be done either through Yarn or NPM as follows:
yarn add es6-promise
or
npm install es6-promise
Once installed, you can incorporate it in your code as follows:
var Promise = require('es6-promise').Promise;
Remember to use string access for catch
and finally
methods in IE<9 as they are reserved keywords in such environments. For instance:
promise['catch'](function(err) {
// Handle error
});
promise['finally'](function() {
// Execute code after promise is settled
});
If you want to polyfill the global environment, you can use the following code snippet:
require('es6-promise').polyfill();
or alternatively:
require('es6-promise/auto');
In-depth details of the ES6-Promise API and how to use promises can be found in the 'JavaScript Promises HTML5Rocks article'. For additional features and debugging options, developers might want to explore the full RSVP.js library which ES6-Promise is a subset of.