onedionys-promise-utilities
v5.0.0
Published
One Dionys (Promise Utilities) - A set of utility functions for working with Promise such as all, race, and resolve.
Downloads
9
Maintainers
Readme
💾 Requirements
Web Browser
- Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera].Internet
- Because many use CDN and to make it easier to find solutions to all problems.
🎯 How To Use
Example Syntax
const { promiseAll, promiseRace, promiseTimeout } = require('promise-utilities');
const promises = [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
// Example of using promiseAll
promiseAll(promises).then(result => {
console.log('All promises resolved:', result);
});
// Example of using promiseRace
promiseRace(promises).then(result => {
console.log('First resolved promise:', result);
});
// Example of using promiseTimeout
const timeout = 1000;
promiseTimeout(timeout).then(() => {
console.log('Timeout reached after', timeout, 'milliseconds');
});
Explanation
promiseAll(promises)
: Resolves all promises in the given array and returns a new promise that resolves with an array of results.promiseRace(promises)
: Resolves the promise that resolves first in the given array and returns a new promise.promiseTimeout(ms)
: Creates a promise that resolves after the specified time (in milliseconds).
Return Value
promiseAll
: Returns a promise that resolves with an array containing the results of all input promises.promiseRace
: Returns a promise that resolves with the value of the first input promise to resolve.promiseTimeout
: Returns a promise that resolves after the specified timeout.
📆 Release Date
- v1.0.0 : 07 March 2024
- v1.0.1 : 11 March 2024
- v4.0.0 : 11 March 2024
- v4.0.1 : 13 March 2024
- v4.0.2 : 18 March 2024
- v5.0.0 : 31 March 2024
🧑 Author
- Facebook : Oned Ionys
- Instagram : @onedionys
- Twitter : @onedionys
- LinkedIn : @onedionys
📝 License
- Copyright © 2024 One Dionys
- One Dionys - Promise Utilities is an open source project licensed under the MIT license
☕️ Suppport & Donation
Love One Dionys - Promise Utilities? Support this project by donating or sharing with others in need.
Made with ❤️ One Dionys