This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/backoff/index.js
2020-11-01 22:46:04 +00:00

32 lines
1.1 KiB
JavaScript

// 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);
};