https://github.com/thysultan/schedula.js
schedula is a priority based work scheduler for javascript
https://github.com/thysultan/schedula.js
priority schedule
Last synced: 4 months ago
JSON representation
schedula is a priority based work scheduler for javascript
- Host: GitHub
- URL: https://github.com/thysultan/schedula.js
- Owner: thysultan
- License: mit
- Created: 2017-01-23T14:00:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-23T21:39:03.000Z (about 9 years ago)
- Last Synced: 2024-04-13T21:11:45.719Z (almost 2 years ago)
- Topics: priority, schedule
- Language: JavaScript
- Size: 13.7 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# schedula.js
priority based work scheduler for javascript.
- ~700 bytes minified+gzipped
[](https://www.npmjs.com/package/schedula) [](https://github.com/thysultan/schedula.js/blob/master/LICENSE.md)
## Browser Support
* Edge
* IE 8+
* Chrome
* Firefox
* Safari
* Node
## Installation
#### direct download
```html
```
#### CDN
```html
```
#### npm
```
npm install schedula --save
```
## Examples
```javascript
// create a fiber
var fiber = schedula(60);
// push work
fiber.push(true, null, (a, b) => {
console.log(a, b);
}, 3, [1, 2]);
// slow things down, this will throttle work to a 20fps budget
schedule.budget = 20;
// speed things up, this will throttle work to a 60fps budget
schedule.budget = 60;
// context
var foo = {
bar: function (a, b) {
console.log(a, b);
}
}
fiber.push(true, foo, foo.bar, 3, [1, 2]);
// manually flush high priority work, without throttling
fiber.flush(true);
// manually flush low priority work, without throttling
fiber.flush(false);
```
- [work cycle timeline visuals](https://rawgit.com/thysultan/schedula.js/master/examples/index.html)
## API
#### push
push work
```javascript
/**
* @param {boolean} priority - true for high priority
* @param {any} context - this context
* @param {function} callback - callback function
* @param {number} length - number of arguments passed
* @param {any[]} arguments - array of arguments passed
*/
```
#### flush
manually flush work sync
```javascript
/**
* @param {boolean} priority - true for high priority
*/
```
#### budget
get/set budget
```javascript
/**
* @type getter/setter
*/
```
#### work
get queued work.
```javascript
/**
* @type getter
*/
```