ts-retry-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

ts-retry-decorator

ts-retry-decorator Based on promise-retry Base Usage

import {Retry} from "ts-retry-decorator";

class Example {
    @Retry({
        retries: 2,
        factor: 2,
        minTimeout: 1 * 1000,
        maxTimeout: 2 * 1000,
        randomize: true
    })
    retryFunction(){
        if(Math.random()*100 > 60)
            throw new Error("Error !!")
    }
}



async function start() {
    console.log('Start')
    const example = new Example()
    await example.retryFunction()
    console.log('Finish')
}

start().catch(reason => console.log(reason))

Package Sidebar

Install

npm i ts-retry-decorator

Weekly Downloads

13

Version

0.0.5

License

none

Unpacked Size

13.4 kB

Total Files

15

Last publish

Collaborators

  • panarama360