Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-idle-callback

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-idle-callback

Browser shim for window.requestIdleCallback

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
192
decreased by-7.69%
Maintainers
1
Weekly downloads
 
Created
Source

Request Idle Callback Shim

For more information refer to Using requestIdleCallback

Install

npm install request-idle-callback

Example

var ric = require('request-idle-callback')
// Executes myNonEssentialWork duting idle time on each frame or fallbacks to using setTimeout to run at most 50ms per frame
ric.requestIdleCallback(myNonEssentialWork);

function myNonEssentialWork (deadline) {
  while (deadline.timeRemaining() > 0)
    doWorkIfNeeded();
}

API

requestIdleCallback(callback(deadline))

deadline is an object containing:

  • deadline.didTimeout boolean indicating if it is still time to deadline.
  • deadline.timeRemaining function that returns remaining time.

cancelIdleCallback(id)

Removes callback from the queue or calls clearTimeout.

Tests

node tests.js

Licencia

MIT

Keywords

FAQs

Package last updated on 29 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc