index.js

- Jump To … +
  index.js backoff.js function_call.js exponential.js fibonacci.js strategy.js

- # index.js

- ¶

       Copyright (c) 2012 Mathieu Turcotte
       Licensed under the MIT license.

      var Backoff = require('./lib/backoff');
      var ExponentialBackoffStrategy = require('./lib/strategy/exponential');
      var FibonacciBackoffStrategy = require('./lib/strategy/fibonacci');
      var FunctionCall = require('./lib/function_call.js');

      module.exports.Backoff = Backoff;
      module.exports.FunctionCall = FunctionCall;
      module.exports.FibonacciStrategy = FibonacciBackoffStrategy;
      module.exports.ExponentialStrategy = ExponentialBackoffStrategy;

- ¶

  Constructs a Fibonacci backoff.

      module.exports.fibonacci = function(options) {
          return new Backoff(new FibonacciBackoffStrategy(options));
      };

- ¶

  Constructs an exponential backoff.

      module.exports.exponential = function(options) {
          return new Backoff(new ExponentialBackoffStrategy(options));
      };

- ¶

  Constructs a FunctionCall for the given function and arguments.

      module.exports.call = function(fn, vargs, callback) {
          var args = Array.prototype.slice.call(arguments);
          fn = args[0];
          vargs = args.slice(1, args.length - 1);
          callback = args[args.length - 1];
          return new FunctionCall(fn, vargs, callback);
      };