@teleology/fp
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -8,11 +8,15 @@ "use strict"; | ||
const retry = (fn, max = 3) => async (...args) => { | ||
for (let i = max - 1; i > -1; i -= 1) { | ||
/* eslint-disable no-await-in-loop */ | ||
const DEFAULT_ROLLOFF = async () => {}; | ||
const retry = (fn, max = 3, rolloff = DEFAULT_ROLLOFF) => async (...args) => { | ||
for (let i = 0; i < max; i += 1) { | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
return await fn(...args); | ||
} catch (e) { | ||
if (!i) { | ||
if (i + 1 >= max) { | ||
throw e; | ||
} | ||
await rolloff(i + 1); | ||
} | ||
@@ -19,0 +23,0 @@ } |
{ | ||
"name": "@teleology/fp", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "A small collection of functional programming utils", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:icarus-sullivan/teleology-fp.git", |
16159
302