0.4.1 • Published 8 years ago

request-idle v0.4.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

requestIdle Build Status

NPM

WARNING: this is not a polyfill for requestIdleCallback, if you are looking for such thing, try this one.

Allocate time for you task to run!

Install

npm install request-idle --save

Usage

requestIdle(Number:duration, Function:task)

Allocate time with duration parameter, and run given task, eg:

requesetIdle(500, function() {
    // task one
    // this will run asap
});

requestIdle(10, function() {
    // task two
    // this will run after task one is finished(about 500ms)
});

An idle object is passed to task, thus you can release the idle by idle.end() before given duration:

requesetIdle(500, function(idle) {
    // task one runned about 200ms
    idle.end();
});

requestIdle(10, function() {
    // task two will be invoked after approximate 200ms
});

requestIdle(Function:task)

If first parameter is passed as function, you'll get an idle that is almost endless. So don't forget to end up the idle when you don't need it any more.

requesetIdle(function(idle) {
    // run you task

    idle.end(); // remember to release
});

idle#end()

Release current idle.

idle#add(Number:ms)

Extend current idle duration.

idle#remain

Get current idle time remaining.

License

MIT.

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago