nanoscheduler
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/nanoscheduler package

1.0.3 • Public • Published

nanoscheduler

npm version build status downloads js-standard-style

Schedule work to be completed when the user agent is idle. Weighs 270 bytes compressed.

Usage

var NanoScheduler = require('nanoscheduler')
 
var scheduler = NanoScheduler()
var i = 10000
while (i--) scheduler.push(() => console.log(`idle time! ${Date.now()}`))

Why?

Just like with window.requestAnimationFrame, it's much more efficient to share a single instance than to call it for each piece of work. There's a significant overhead when scheduling small amounts of work. This package allows sharing a scheduler as a singleton, which makes it particularly useful to be shared between multiple applications.

API

scheduler = NanoScheduler()

Create a new scheduler instance. The instance is shared as a singleton on window (if available).

scheduler.push(cb)

Push a callback into the scheduler, to be executed when the user agent is idle.

Installation

$ npm install nanoscheduler

License

Apache-2.0

Package Sidebar

Install

npm i nanoscheduler

Weekly Downloads

42,856

Version

1.0.3

License

Apache-2.0

Unpacked Size

15.5 kB

Total Files

6

Last publish

Collaborators

  • mreinstein
  • benlyn
  • s3ththompson
  • yoshuawuyts
  • bret
  • lrlna
  • yerkopalma
  • juliangruber
  • timwis
  • ahdinosaur
  • toddself
  • sethvincent
  • maxogden
  • shama
  • freeman-lab
  • feross
  • emilbayes
  • colingourlay
  • jameskyburz
  • almost
  • slaskis
  • ungoldman
  • graforlock
  • tornqvist
  • amongiants
  • goto-bus-stop
  • mafintosh