1 var retry = require('../lib/retry');
3 function attemptAsyncOperation(someInput, cb) {
11 var operation = retry.operation(opts);
13 operation.attempt(function(currentAttempt) {
14 failingAsyncOperation(someInput, function(err, result) {
16 if (err && err.message === 'A fatal error') {
21 if (operation.retry(err)) {
25 cb(operation.mainError(), operation.errors(), result);
30 attemptAsyncOperation('test input', function(err, errors, result) {
34 console.warn('result:');
38 function failingAsyncOperation(input, cb) {
39 return setImmediate(cb.bind(null, new Error('A fatal error')));