https://github.com/callmecavs/ique
A queue that runs tasks when the browser is idle.
https://github.com/callmecavs/ique
queue requestidlecallback
Last synced: 12 months ago
JSON representation
A queue that runs tasks when the browser is idle.
- Host: GitHub
- URL: https://github.com/callmecavs/ique
- Owner: callmecavs
- Created: 2018-02-24T01:30:11.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T21:20:36.000Z (about 8 years ago)
- Last Synced: 2025-04-09T06:01:43.414Z (12 months ago)
- Topics: queue, requestidlecallback
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ique
[](https://www.npmjs.com/package/ique) [](https://www.npmjs.com/package/ique) [](http://standardjs.com/)
A queue that runs tasks when the browser is idle.
## Install
```sh
$ npm install ique --save
```
## Use
```javascript
import ique from 'ique'
// create a queue, passing a timeout (default shown)
// more on timeouts here: https://goo.gl/4jLPWz
const queue = ique(1000)
// add tasks to it, which will be run automatically when the browser is idle
for (let i = 0; i < 1000; i++) {
queue.add({
func: x => console.log(x),
args: ['test']
})
}
// constructor and add can be chained
const priorityQueue = ique(100)
.add({
func: x => console.log(x),
args: [0]
})
.add({
func: y => console.log(y),
args: [1]
})
```
## Browser Support
Requires [`requestIdleCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback), and as such supports the following:
* Chrome 47+
* Firefox 55+
* Opera 34+
Consider using this [shim](https://gist.github.com/paullewis/55efe5d6f05434a96c36) in unsupported browsers.
## License
[MIT](https://opensource.org/licenses/MIT). © 2018 Michael Cavalea