Comparing version 1.1.1 to 1.2.0
{ | ||
"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. | ||
[![npm version](https://img.shields.io/npm/v/polly-js.svg?style=flat-square)](https://www.npmjs.org/package/polly-js) | ||
[![npm downloads](https://img.shields.io/npm/dm/polly-jst.svg?style=flat-square)](http://npm-stat.com/charts.html?package=polly-js&from=2015-09-01) | ||
[![npm downloads](https://img.shields.io/npm/dm/polly-js.svg?style=flat-square)](http://npm-stat.com/charts.html?package=polly-js&from=2015-09-01) | ||
[![Dependency Status](https://david-dm.org/mauricedb/polly-js.svg)](https://david-dm.org/mauricedb/polly-js) | ||
@@ -17,3 +17,3 @@ [![Build Status](https://travis-ci.org/mauricedb/polly-js.svg?branch=master)](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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
269504
22
389
49
1
1