Comparing version 0.2.1 to 0.3.0
@@ -19,10 +19,15 @@ /* | ||
*/ | ||
module.exports.fibonnaci = module.exports.fibonacci = function(options) { | ||
module.exports.fibonacci = function(options) { | ||
return new Backoff(new FibonacciBackoffStrategy(options)); | ||
}; | ||
module.exports.fibonnaci = function(options) { | ||
console.log('Deprecated: use backoff.fibonacci instead.'); | ||
return new module.exports.fibonacci(options); | ||
}; | ||
/** | ||
* Constructs an exponential backoff. | ||
* @param options Exponential strategy arguments. | ||
* @see FibonnaciBackoffStrategy | ||
* @see ExponentialBackoffStrategy | ||
*/ | ||
@@ -29,0 +34,0 @@ module.exports.exponential = function(options) { |
@@ -11,6 +11,6 @@ /* | ||
/** | ||
* Fibonnaci backoff strategy. | ||
* Fibonacci backoff strategy. | ||
* @extends BackoffStrategy | ||
*/ | ||
function FibonnaciBackoffStrategy(options) { | ||
function FibonacciBackoffStrategy(options) { | ||
BackoffStrategy.call(this, options); | ||
@@ -20,6 +20,6 @@ this.backoffDelay_ = 0; | ||
} | ||
util.inherits(FibonnaciBackoffStrategy, BackoffStrategy); | ||
util.inherits(FibonacciBackoffStrategy, BackoffStrategy); | ||
/** @inheritDoc */ | ||
FibonnaciBackoffStrategy.prototype.next_ = function() { | ||
FibonacciBackoffStrategy.prototype.next_ = function() { | ||
var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay()); | ||
@@ -32,3 +32,3 @@ this.nextBackoffDelay_ += this.backoffDelay_; | ||
/** @inheritDoc */ | ||
FibonnaciBackoffStrategy.prototype.reset_ = function() { | ||
FibonacciBackoffStrategy.prototype.reset_ = function() { | ||
this.nextBackoffDelay_ = this.getInitialDelay(); | ||
@@ -38,3 +38,3 @@ this.backoffDelay_ = 0; | ||
module.exports = FibonnaciBackoffStrategy; | ||
module.exports = FibonacciBackoffStrategy; | ||
{ | ||
"name": "backoff", | ||
"description": "Exponential and Fibonacci backoffs.", | ||
"version": "0.2.1", | ||
"description": "Fibonacci and exponential backoffs.", | ||
"version": "0.3.0", | ||
"author": "Mathieu Turcotte <turcotte.mat@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": ["backoff", "fibonacci", "exponential"], |
# Backoff for Node.js [![Build Status](https://secure.travis-ci.org/MathieuTurcotte/node-backoff.png?branch=master)](http://travis-ci.org/MathieuTurcotte/node-backoff) | ||
Backoff implementation for Node.js. | ||
Fibonacci and exponential backoffs for Node.js. | ||
@@ -99,3 +99,3 @@ ## Installation | ||
Constructs a new backoff object from a specific backoff strategy. The backoff | ||
strategy must implement the `BackoffStrategy` interface defined bellow. | ||
strategy must implement the `BackoffStrategy`interface defined bellow. | ||
@@ -139,6 +139,30 @@ #### backoff.backoff() | ||
Reset the backoff delay to its initial value. | ||
Resets the backoff delay to its initial value. | ||
### Class ExponentialStrategy | ||
Exponential (10, 20, 40, 80, etc.) backoff strategy implementation. | ||
#### new ExponentialStrategy([options]) | ||
The options are: | ||
- randomisationFactor: defaults to 0, must be between 0 and 1 | ||
- initialDelay: defaults to 100 ms | ||
- maxDelay: defaults to 10000 ms | ||
### Class FibonacciStrategy | ||
Fibonnaci (10, 10, 20, 30, 50, etc.) backoff strategy implementation. | ||
#### new FibonacciStrategy([options]) | ||
The options are: | ||
- randomisationFactor: defaults to 0, must be between 0 and 1 | ||
- initialDelay: defaults to 100 ms | ||
- maxDelay: defaults to 10000 ms | ||
## License | ||
This code is free to use under the terms of the [MIT license](http://mturcotte.mit-license.org/). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27100
519
167