Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.1KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) 2012 Mathieu Turcotte
  2. // Licensed under the MIT license.
  3. var Backoff = require('./lib/backoff');
  4. var ExponentialBackoffStrategy = require('./lib/strategy/exponential');
  5. var FibonacciBackoffStrategy = require('./lib/strategy/fibonacci');
  6. var FunctionCall = require('./lib/function_call.js');
  7. module.exports.Backoff = Backoff;
  8. module.exports.FunctionCall = FunctionCall;
  9. module.exports.FibonacciStrategy = FibonacciBackoffStrategy;
  10. module.exports.ExponentialStrategy = ExponentialBackoffStrategy;
  11. // Constructs a Fibonacci backoff.
  12. module.exports.fibonacci = function(options) {
  13. return new Backoff(new FibonacciBackoffStrategy(options));
  14. };
  15. // Constructs an exponential backoff.
  16. module.exports.exponential = function(options) {
  17. return new Backoff(new ExponentialBackoffStrategy(options));
  18. };
  19. // Constructs a FunctionCall for the given function and arguments.
  20. module.exports.call = function(fn, vargs, callback) {
  21. var args = Array.prototype.slice.call(arguments);
  22. fn = args[0];
  23. vargs = args.slice(1, args.length - 1);
  24. callback = args[args.length - 1];
  25. return new FunctionCall(fn, vargs, callback);
  26. };