Background tasks API abstraction. Do background work during browser idle time.
npm install downtimejs
const downtime = require("downtime")
`
API
$3
- Schedule callback to run during next idle period
- Return an id for cancellation purposes
- Callback is invoked with an IdleDeadline object
`js
downtime.do(function(deadline) {
// Do background work
})
`
$3
- Cancel callback represented by id
`js
var id = downtime.do(doBackgroundWork)
downtime.dont(id)
`
Notes
- Downtime uses requestIdleCallback and cancelIdleCallback` where available