https://github.com/dafrok/public-interval
Create a public interval handler to manage a group of processors.
https://github.com/dafrok/public-interval
Last synced: 3 months ago
JSON representation
Create a public interval handler to manage a group of processors.
- Host: GitHub
- URL: https://github.com/dafrok/public-interval
- Owner: Dafrok
- Created: 2016-02-03T06:41:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-03T16:18:20.000Z (over 10 years ago)
- Last Synced: 2025-02-20T13:20:04.706Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# public-interval.js
## Intro
Create a public interval handler to manage a group of processors.
## Install
```
$ npm install public-interval
```
## Usage
```javascript
import PublicInterval from 'public-interval'
let pi = new PublicInterval()
pi.setProcessor('my-processor', function () {
console.log('My processor is running.')
})
pi.go()
```
## Option
- timer {number} Interval time of this handler.
- processor {object} Initial processors of this handler.
- autorun {boolean} Whether run this handler when initialized.
## API
### pi.go
- description
- Start this interval handler.
### pi.stop
- description
- Stop this interval handler.
### pi.setProcessor
- description
- Set a new processor in this interval handler.
- param
- name(optional) {string} The name of this processor. It's a unique value.
- fn {function} The processor.
### pi.removeProcessor
- description
- Remove a processor in this interval by name.
- param
- name {string} The name of a processor which works in this interval handler.
### pi.setTimer
- description
- Set interval time for this interval handler.
- param
- time {number} The interval time of this interval handler.