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

    1.2.0 • Public • Published

    async-retry.ts

    async await version of co-retry.js, which can be used in both TypeScript and JavaScript.

    npm download NPM version Build Status Dependencies Status Coverage Status code style: prettier

    996.icu LICENSE

    [Quality gate](https://sonarcloud.io /dashboard?id=Jeff-Tian_async-retry.ts)

    安装

    npm install async-retry.ts --save

    用法

    简单示例:

    TypeScript:

    非 async 版:
    import Action from 'async-retry.ts'
     
    const action = () => {}
    const handlers = [
      {
        error: 'error1',
        handler: yourHandler1,
      },
      {
        error: 'error2',
        handler: yourHandler2,
      },
    ]
     
    Action.retry(action, 3, handlers)
    async 版:
    import Action from 'async-retry.ts'
     
    const action = async()=>{}
    const handlers = [{
      error: 'error1',
      handler: async yourHandler1()=>{}
    }, {
      error: 'error2',
      handler: async yourHandler2()=>{}
    }]
     
    await Action.retryAsync(action, 3, handlers)

    JavaScript:

    非 async 版:
    const Action = require('async-retry.ts').default
     
    const action = () => {}
    const handlers = [
      {
        error: 'error1',
        handler: yourHandler1,
      },
      {
        error: 'error2',
        handler: yourHandler2,
      },
    ]
     
    Action.retry(action, 3, handlers)
    async 版
    const Action =require('async-retry.ts').default
     
    const action = async()=>{}
    const handlers = [{
      error: 'error1',
      handler: async yourHandler1()=>{}
    }, {
      error: 'error2',
      handler: async yourHandler2()=>{}
    }]
     
    await Action.retryAsync(action, 3, handlers)

    完整示例:

    开发

    1. 修改代码后跑

      npm test

      确保测试通过。

    2. git commit

    3. npm version patch/minor/major

    4. npm publish

    Keywords

    none

    Install

    npm i async-retry.ts

    DownloadsWeekly Downloads

    5,776

    Version

    1.2.0

    License

    ISC

    Unpacked Size

    22.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar