1.0.0 • Published 7 years ago

fib-interval v1.0.0

Weekly downloads
27
License
ISC
Repository
github
Last release
7 years ago

fib-interval NPM version Build Status

setInterval using a series of incrementing Fibonacci durations

Install

$ npm install --save fib-interval

Usage

  • Unlike setInterval
    • The delay provided must be a numeric Array with the first 2 values to use
    • To stop a timer you must call .clear() on the instance
    • To snoop out the current delay time, call .delay() on the instance

For Example:

'use strict';

var fibInterval = require('fib-interval');

// fibInterval(Function, [Number, Number]) : Object

var instance = fibInterval(function () {
  var delay = instance.delay();

  console.log(delay);

  if (delay === 800) {
    instance.clear();
    console.log('fatto');
  }
}, [0, 100]);

// ==> results:
// 0
// 100
// 100
// 200
// 300
// 500
// 800
// fatto

License

ISC © Buster Collings