Skip to content

A queue that runs tasks when the browser is idle.

Notifications You must be signed in to change notification settings

callmecavs/ique

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ique

ique on NPM ique Downloads on NPM Standard JavaScript Style

A queue that runs tasks when the browser is idle.

Install

$ npm install ique --save

Use

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, and as such supports the following:

  • Chrome 47+
  • Firefox 55+
  • Opera 34+

Consider using this shim in unsupported browsers.

License

MIT. © 2018 Michael Cavalea