https://github.com/busterc/fib-interval
:repeat: setInterval using a series of incrementing Fibonacci durations
https://github.com/busterc/fib-interval
backoff fibonacci setinterval settimeout
Last synced: 6 months ago
JSON representation
:repeat: setInterval using a series of incrementing Fibonacci durations
- Host: GitHub
- URL: https://github.com/busterc/fib-interval
- Owner: busterc
- Created: 2017-03-14T20:28:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-25T21:51:02.000Z (over 7 years ago)
- Last Synced: 2025-06-01T17:07:56.429Z (7 months ago)
- Topics: backoff, fibonacci, setinterval, settimeout
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fib-interval [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
> setInterval using a series of incrementing Fibonacci durations
## Install
```sh
$ 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:**
```js
'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](http://about.me/buster)
[npm-image]: https://badge.fury.io/js/fib-interval.svg
[npm-url]: https://npmjs.org/package/fib-interval
[travis-image]: https://travis-ci.org/busterc/fib-interval.svg?branch=master
[travis-url]: https://travis-ci.org/busterc/fib-interval