blend / Promise Utils
Licence: mit
Lodash-like, dependency-free utilities for native ES6 promises.
Stars: ✭ 268
Programming Languages
javascript
184084 projects - #8 most used programming language
typescript
32286 projects
Projects that are alternatives of or similar to Promise Utils
Javascript-Interview-Preparation
A curated collection of javascript interview questions & solutions.
Stars: ✭ 163 (-39.18%)
Mutual labels: promises, lodash
underwater
~2kb - ES6 Collection of helper functions. Lodash like
Stars: ✭ 18 (-93.28%)
Mutual labels: lodash
underscore.haz
🔍 _.haz() is like _.has() but this underscore and/or lodash mixin lets you do deep object key existence checking with a dot denoted string, for example 'a.b.c'
Stars: ✭ 13 (-95.15%)
Mutual labels: lodash
fnbr.js
A library to interact with Epic Games' Fortnite HTTP and XMPP services
Stars: ✭ 73 (-72.76%)
Mutual labels: promises
node-google-calendar
Simple node module that supports Google Calendar API
Stars: ✭ 76 (-71.64%)
Mutual labels: promises
Zio
ZIO — A type-safe, composable library for async and concurrent programming in Scala
Stars: ✭ 3,167 (+1081.72%)
Mutual labels: promises
eslint-plugin-lodash-template
ESLint plugin for John Resig-style micro template, Lodash's template, Underscore's template and EJS.
Stars: ✭ 15 (-94.4%)
Mutual labels: lodash
apr
this is like caolan/async which is like lodash but async, but awaitful
Stars: ✭ 75 (-72.01%)
Mutual labels: promises
tall
Promise-based, No-dependency URL unshortner (expander) module for Node.js
Stars: ✭ 56 (-79.1%)
Mutual labels: promises
promise-utils
Promise-utils is a dependency-free JavaScript/TypeScript library that provides Lodash-like utility functions for dealing with native ES6 promises.
Installation
$ npm install blend-promise-utils
Usage Example
const promiseUtils = require('blend-promise-utils')
const { promises: fs } = require('fs')
const request = require('request-promise-native');
const isEmpty = require('lodash.isempty');
const MS_IN_SECOND = 1000;
async function main() {
const cachedResponse = promiseUtils.memoize(
async (contents) => request(contents.url),
contents => contents.url,
15 * MS_IN_SECOND // contents could change
);
const fileContents = await promiseUtils.map(
['file1', 'file2', 'file3'],
async fileName => {
const rawData = await fs.readFile(fileName);
return JSON.parse(rawData);
},
);
while (true) {
await promiseUtils.delay(150); // avoid slamming CPU
await promiseUtils.mapSeries(
fileContents,
async contents => {
const remoteData = await cachedResponse(contents);
const { results, errors } = await promiseUtils.settleAll([
asyncFunction1(),
asyncFunction2(),
asyncFunction3(),
]);
if (!isEmpty(errors)) {
throw new Error(`Unable to settle all functions: ${JSON.stringify(errors)}`);
} else {
return results;
}
}
)
}
await promiseUtils.retry(flakyFunction, { maxAttempts: 3, delayMs: 150 })(flakyFunctionArgument);
await promiseUtils.timeout(longFunction, 60 * MS_IN_SECOND)(longFunctionArgument);
}
main()
API
Test
$ npm test
Documentation
Build docs
$ make docs
Push docs to Github
$ make push-docs
License
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].