UNPKG

ts-retry

Version:

A little retry tool to execute a function until the function is successful. Can also bind a timeout to a function. This lib is usable in typescript, in javascript, in node, in SPA tools (rest, Vue, Svelte...) and browser (available in ESM and common js fo

14 lines (13 loc) 384 B
export class TooManyTries extends Error { constructor(lastResult = undefined) { super("function did not complete within allowed number of attempts"); this.lastResult = lastResult; this.tooManyTries = true; } getLastResult() { return this.lastResult; } } export function isTooManyTries(error) { return error.tooManyTries === true; }