JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 365
  • Score
    100M100P100Q122167F
  • License MIT

Create an accurate interval that does not skew over time.

Package Exports

  • accurate-interval

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 (accurate-interval) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

accurate-interval

Create an accurate interval that does not skew over time.

NPM

Usage

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: string - 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