Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanziw/repeating-task-manager
Repeating task manager using tail recursion for Node.js
https://github.com/kanziw/repeating-task-manager
Last synced: about 2 months ago
JSON representation
Repeating task manager using tail recursion for Node.js
- Host: GitHub
- URL: https://github.com/kanziw/repeating-task-manager
- Owner: kanziw
- License: mit
- Created: 2018-05-24T13:11:36.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-09-27T20:44:28.000Z (over 1 year ago)
- Last Synced: 2024-10-11T20:08:26.019Z (3 months ago)
- Language: TypeScript
- Size: 246 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# RepeatingTaskManager
> Repeating task manager using tail recursion for Node.js* [NPM repository](https://www.npmjs.com/package/repeating-task-manager)
## Install
### Using NPM
```bash
npm install repeating-task-manager
```### Using Yarn
```bash
yarn add repeating-task-manager
```## Usage
## Simple example
```javascript
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 `` Unique ID for task
* interval `` Interval times(ms) between before task and after task
* taskFunction: `` Function to be executed repeatedly
* options
* onError: ``
* err: ``## rtm.execute
> Execute task function immediately### (taskId[, options]) => void (or depends on task function.)
* taskId ``
* options
* isRegister `` Default: false, True only when registered.
* ...CUSTOM_PROPERTIES## rtm.clear
> Clear(remove) task.### (taskId) => void
* taskId ``## 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