1.0.9 • Published 8 years ago

accurate-interval v1.0.9

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

accurate-interval

Create an accurate interval that does not skew over time.

NPM

Build Status Coverage Status Dependency Status devDependency Status

API

var interval = accurateInterval(func, interval, opts)

  • func: function - Function to call ever interval ms. func takes one argument, scheduledTime, which is the timestamp in milliseconds the callback was scheduled for.
  • interval: number - Interval (in ms) with which to call func.
  • opts
    • aligned: boolean - Optional. Align timestamps. Default is false.
    • immediate: boolean - Optional. Call func immediately as well. Default is false.

Example

var accurateInterval = require('accurate-interval');
var foo = accurateInterval(function(scheduledTime) {
    console.log('Actual time: ' + Date.now() + ' -- Scheduled time: ' + scheduledTime);
}, 2000, {aligned: true, immediate: true});

setTimeout(function() {
    foo.clear();
}, 10000);

License

MIT

1.0.9

8 years ago

1.0.8

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago