Comparing version
{ | ||
"name": "polly-js", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Transient exception handling", | ||
@@ -5,0 +5,0 @@ "main": "src/polly.js", |
# polly-js | ||
Transient exception handling for JavaScript | ||
Transient exception handling for JavaScript made easy. | ||
[](https://www.npmjs.org/package/polly-js) | ||
[](http://npm-stat.com/charts.html?package=polly-js&from=2015-09-01) | ||
[](http://npm-stat.com/charts.html?package=polly-js&from=2015-09-01) | ||
[](https://david-dm.org/mauricedb/polly-js) | ||
@@ -17,3 +17,3 @@ [](https://travis-ci.org/mauricedb/polly-js) | ||
Try to load the Google home page and rety twice if it fails | ||
Try to load the Google home page and retry twice if it fails | ||
@@ -33,2 +33,15 @@ ```JavaScript | ||
```JavaScript | ||
polly | ||
.retry(2) | ||
.executeForNode(function (cb) { | ||
fs.readFile(path.join(__dirname, './hello.txt'), cb); | ||
}, function (err, data) { | ||
if (err) { | ||
console.error('Failed trying three times', err) | ||
} else { | ||
console.log(data) | ||
} | ||
}); | ||
``` | ||
@@ -35,0 +48,0 @@ ## Acknowledgements |
@@ -61,2 +61,18 @@ /** | ||
function executeForNode(config, fn, callback) { | ||
var count = 0; | ||
function internalCallback(err, data) { | ||
if (err && count < config.count) { | ||
count++; | ||
fn(internalCallback); | ||
} else { | ||
callback(err, data); | ||
} | ||
} | ||
fn(internalCallback); | ||
} | ||
return { | ||
@@ -70,3 +86,4 @@ retry: function (count) { | ||
execute: execute.bind(null, config), | ||
executeForPromise: executeForPromise.bind(null, config) | ||
executeForPromise: executeForPromise.bind(null, config), | ||
executeForNode: executeForNode.bind(null, config) | ||
}; | ||
@@ -73,0 +90,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
269504
1.48%22
15.79%389
39.93%49
36.11%2
100%1
Infinity%