@handy-common-utils/promise-utils
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -97,2 +97,3 @@ /** | ||
* @example | ||
* // Capture errors in the returned array | ||
* const attributesAndPossibleErrors = await PromiseUtils.inParallel(5, topicArns, async (topicArn) => { | ||
@@ -103,2 +104,3 @@ * const topicAttributes = (await sns.getTopicAttributes({ TopicArn: topicArn }).promise()).Attributes!; | ||
* | ||
* // Abort on the first error | ||
* let results: Array<JobResult>; | ||
@@ -105,0 +107,0 @@ * try { |
@@ -131,2 +131,3 @@ "use strict"; | ||
* @example | ||
* // Capture errors in the returned array | ||
* const attributesAndPossibleErrors = await PromiseUtils.inParallel(5, topicArns, async (topicArn) => { | ||
@@ -137,2 +138,3 @@ * const topicAttributes = (await sns.getTopicAttributes({ TopicArn: topicArn }).promise()).Attributes!; | ||
* | ||
* // Abort on the first error | ||
* let results: Array<JobResult>; | ||
@@ -139,0 +141,0 @@ * try { |
{ | ||
"name": "@handy-common-utils/promise-utils", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Promise related utilities", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -63,11 +63,16 @@ # @handy-common-utils/promise-utils | ||
// inParallel(...) | ||
const topicArns = topics.map(topic => topic.TopicArn!); | ||
await inParallel(5, topicArns, async topicArn => { | ||
// Capture errors in the returned array | ||
const attributesAndPossibleErrors = await PromiseUtils.inParallel(5, topicArns, async (topicArn) => { | ||
const topicAttributes = (await sns.getTopicAttributes({ TopicArn: topicArn }).promise()).Attributes!; | ||
const topicDetails = { ...topicAttributes, subscriptions: [] } as any; | ||
if (this.shouldInclude(topicArn)) { | ||
inventory.snsTopicsByArn.set(topicArn, topicDetails); | ||
} | ||
return topicAttributes; | ||
}); | ||
// Abort on the first error | ||
let results: Array<JobResult>; | ||
try { | ||
results = await PromiseUtils.inParallel(100, jobs, async (job) => processor.process(job), { abortOnError: true }); | ||
} catch (error) { | ||
// handle the error | ||
} | ||
``` | ||
@@ -501,2 +506,3 @@ | ||
```ts | ||
// Capture errors in the returned array | ||
const attributesAndPossibleErrors = await PromiseUtils.inParallel(5, topicArns, async (topicArn) => { | ||
@@ -507,2 +513,3 @@ const topicAttributes = (await sns.getTopicAttributes({ TopicArn: topicArn }).promise()).Attributes!; | ||
// Abort on the first error | ||
let results: Array<JobResult>; | ||
@@ -509,0 +516,0 @@ try { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76370
581
772