Name: js-handler/node_modules/restify/node_modules/backoff/lib/strategy/fibonacci.js 
1:
/*
2:
 * Copyright (c) 2012 Mathieu Turcotte
3:
 * Licensed under the MIT license.
4:
 */
5:
 
6:
var util = require('util');
7:
 
8:
var BackoffStrategy = require('./strategy');
9:
 
10:
/**
11:
 * Fibonacci backoff strategy.
12:
 * @extends BackoffStrategy
13:
 */
14:
function FibonacciBackoffStrategy(options) {
15:
    BackoffStrategy.call(this, options);
16:
    this.backoffDelay_ = 0;
17:
    this.nextBackoffDelay_ = this.getInitialDelay();
18:
}
19:
util.inherits(FibonacciBackoffStrategy, BackoffStrategy);
20:
 
21:
/** @inheritDoc */
22:
FibonacciBackoffStrategy.prototype.next_ = function() {
23:
    var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay());
24:
    this.nextBackoffDelay_ += this.backoffDelay_;
25:
    this.backoffDelay_ = backoffDelay;
26:
    return backoffDelay;
27:
};
28:
 
29:
/** @inheritDoc */
30:
FibonacciBackoffStrategy.prototype.reset_ = function() {
31:
    this.nextBackoffDelay_ = this.getInitialDelay();
32:
    this.backoffDelay_ = 0;
33:
};
34:
 
35:
module.exports = FibonacciBackoffStrategy;