New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

batch-retry

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-retry - npm Package Compare versions

Comparing version

to
0.1.1

2

lib/batch-retry.js

@@ -20,3 +20,3 @@ const echo = input => input

shouldRetry: defaultShouldRetryHandler,
maxRetries: 5,
maxRetries: 3,
onlyFinalResult: true,

@@ -23,0 +23,0 @@ executor: echo

{
"name": "batch-retry",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -84,3 +84,3 @@ # batch-retry

// Run the process
simpleExecutorWithBatchRetry(input).then(console.log)
simpleExecutorWithBatchRetry([1, 2, 3]).then(console.log)
// will output all the result [[1],[evenError, evenError, evenError, evenError, evenError],[3]]

@@ -98,3 +98,3 @@ // if onlyFinalResult set to true, it will only output [1, evenError, 3]

// Run the process
simpleExecutorWithBatchRetry(input).then(console.log)
simpleExecutorWithBatchRetry([1, 2, 3]).then(console.log)
}

@@ -111,3 +111,3 @@ ```

- Function: (task, result, executedTimes) = > Boolean
- `options.maxRetries`: Max retry times. *Default: `5`*
- `options.maxRetries`: Max retry times. *Default: `3`*
- Number

@@ -114,0 +114,0 @@ - `options.onlyFinalResult`: Representing if it should only returns the final result. If setting to false, it will returns all results instead. For example, having final result: `[1, error, 3]` and all results: `[[1], [error, error, error, error, error], [3]]`, it means only the second task failed, and after five retries, it still failed. *Default: `true`*

@@ -31,3 +31,3 @@ const BatchRetry = require('../../lib/batch-retry')

const executor = numbers => numbers.map(each => (each % 2 === 0) ? evenError : each)
const batchRetry = new BatchRetry({executor, onlyFinalResult: false})
const batchRetry = new BatchRetry({executor, onlyFinalResult: false, maxRetries: 5})
it('Should throw when run an empty tasks', async () => {

@@ -68,3 +68,3 @@ await batchRetry.run([]).catch(e => expect(e.message).toMatch(/No tasks to run!/))

)
const batchRetry = new BatchRetry({executor, onlyFinalResult: false})
const batchRetry = new BatchRetry({executor, onlyFinalResult: false, maxRetries: 5})
it('Should throw when run an empty tasks', async () => {

@@ -71,0 +71,0 @@ await batchRetry.run([]).catch(e => expect(e.message).toMatch(/No tasks to run!/))