Software: Apache. PHP/7.3.33 uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) Safe-mode: OFF (not secure) /lib/node_modules/npm/node_modules/promise-retry/node_modules/retry/example/ drwxr-xr-x |
Viewing file: Select action/file-type: var retry = require('../lib/retry'); function attemptAsyncOperation(someInput, cb) { var opts = { retries: 2, factor: 2, minTimeout: 1 * 1000, maxTimeout: 2 * 1000, randomize: true }; var operation = retry.operation(opts); operation.attempt(function(currentAttempt) { failingAsyncOperation(someInput, function(err, result) { if (err && err.message === 'A fatal error') { operation.stop(); return cb(err); } if (operation.retry(err)) { return; } cb(operation.mainError(), operation.errors(), result); }); }); } attemptAsyncOperation('test input', function(err, errors, result) { console.warn('err:'); console.log(err); console.warn('result:'); console.log(result); }); function failingAsyncOperation(input, cb) { return setImmediate(cb.bind(null, new Error('A fatal error'))); } |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0036 ]-- |