1.3.0 • Published 3 years ago

repeating-task-manager v1.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

RepeatingTaskManager

Repeating task manager using tail recursion for Node.js

Install

Using NPM

npm install repeating-task-manager

Using Yarn

yarn add repeating-task-manager

Usage

Simple example

import RepeatingTaskManager from 'repeating-task-manager'

const rtm = new RepeatingTaskManager()

const taskKey = 'TASK_KEY'
let cnt = 0
rtm.register(taskKey, 10, () => console.log(`[${++cnt}] TASK!`))

setTimeout(() => rtm.clear(taskKey), 1000)

// [1] TASK!
// [2] TASK!
// [3] TASK!
// [4] TASK!
// [5] TASK!
// [6] TASK!
// [7] TASK!
// [8] TASK!
// [9] TASK!
// [10] TASK!
// ....

rtm.register

Register task. Throws an Error when an already registered task key is entered.

(taskId, interval, taskFunction, options) => void

  • taskId <string> Unique ID for task
  • interval <number> Interval times(ms) between before task and after task
  • taskFunction: <Function> Function to be executed repeatedly
  • options
    • onError: <Function>
      • err: <Error>

rtm.execute

Execute task function immediately

(taskId, options) => void (or depends on task function.)

  • taskId <string>
  • options
    • isRegister <boolean> Default: false, True only when registered.
    • ...CUSTOM_PROPERTIES

rtm.clear

Clear(remove) task.

(taskId) => void

  • taskId <string>

rtm.clearAll

Clear(remove) all tasks.

() => void

rtm.pause

Pause all tasks without param. Pause task with taskId.

(taskId) => void

rtm.resume

Resume all tasks without param. Resume task with taskId.

(taskId) => void

1.3.0-rc.2

3 years ago

1.3.0-rc.0

3 years ago

1.3.0-rc.1

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.3.0

3 years ago

1.2.1

4 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.0

7 years ago