JSPM

downtime

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q24578F
  • License ISC

Background tasks API abstraction. Do background work during browser idle time.

Package Exports

  • downtime

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (downtime) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

downtime

Do background work during browser idle time.

const downtime = require("downtime")

API

downtime.do(callback)

  • Schedule callback to run during next idle period
  • Return an id for cancellation purposes
  • Callback is invoked with an IdleDeadline object
downtime.do(function(deadline) {
  // Do background work
})

downtime.dont(id)

  • Cancel callback represented by id
var id = downtime.do(doBackgroundWork)
downtime.dont(id)

Notes

  • Downtime uses requestIdleCallback and cancelIdleCallback where available
  • Fallback technique is based on this gist
  • For best performance, avoid DOM manipulation during idle time

Compatibility