New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

polly-js

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polly-js - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

examples/browser/jQuery.html

9

package.json
{
"name": "polly-js",
"version": "1.1.0",
"version": "1.1.1",
"description": "Transient exception handling",
"main": "src/polly.js",
"scripts": {
"test": "mocha tests",
"test:watch": "npm test -- --watch"
"test": "istanbul cover ./node_modules/mocha/bin/_mocha tests",
"test:watch": "mocha tests --watch",
"report-coverage": "cat ./coverage/lcov.info | ./node_modules/.bin/codecov"
},

@@ -32,4 +33,6 @@ "repository": {

"chai-as-promised": "^5.1.0",
"codecov.io": "^0.1.6",
"gulp": "^3.9.0",
"gulp-mocha": "^2.1.3",
"istanbul": "^0.3.21",
"mocha": "^2.3.2",

@@ -36,0 +39,0 @@ "request-promise": "^0.4.3"

# polly-js
Transient exception handling for JavaScript
[![NPM](https://nodei.co/npm/polly-js.png)](https://npmjs.org/package/polly-js)
[![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)
[![Dependency Status](https://david-dm.org/mauricedb/polly-js.svg)](https://david-dm.org/mauricedb/polly-js)
[![Build Status](https://travis-ci.org/mauricedb/polly-js.svg?branch=master)](https://travis-ci.org/mauricedb/polly-js)
[![codecov.io](http://codecov.io/github/mauricedb/polly-js/coverage.svg?branch=master)](http://codecov.io/github/mauricedb/polly-js?branch=master)

@@ -21,3 +23,2 @@ Polly-js is a library to help developers recover from transient errors using policies like retry or wait and retry.

.executeForPromise(function () {
count++;
return requestPromise('http://www.google.com');

@@ -24,0 +25,0 @@ })

@@ -5,3 +5,17 @@ /**

module.exports = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.polly = factory();
}
}(this, function () {
'use strict';

@@ -49,5 +63,5 @@ function execute(config, cb) {

return {
retry: function () {
retry: function (count) {
var config = {
count: 1
count: count || 1
};

@@ -61,2 +75,2 @@

}
}());
}));

@@ -5,2 +5,4 @@ /**

'use strict';
var chai = require('chai');

@@ -57,2 +59,19 @@ var chaiAsPromised = require('chai-as-promised');

it('should retry five times after an error and still fail', function () {
var count = 0;
try {
polly
.retry(5)
.execute(function () {
count++;
throw new Error("Wrong value");
});
}
catch (ex) {
}
count.should.equal(6);
});
it('should retry once after an error and succeed', function () {

@@ -62,3 +81,4 @@ var count = 0;

var result = polly
.retry().execute(function () {
.retry()
.execute(function () {
count++;

@@ -75,2 +95,20 @@ if (count === 1) {

});
it('should retry four after an error and succeed', function () {
var count = 0;
var result = polly
.retry(5)
.execute(function () {
count++;
if (count < 5) {
throw new Error("Wrong value");
}
return 42;
});
result.should.equal(42);
count.should.equal(5);
});
});

@@ -118,2 +156,20 @@

it('should retry five times after an error and still fail', function () {
var count = 0;
return polly
.retry(5)
.executeForPromise(function () {
return new Promise(function (resolve, reject) {
count++;
reject(new Error("Wrong value"));
});
})
.should.eventually
.be.rejected
.then(function () {
count.should.equal(6);
});
});
it('should retry once after an error and succeed', function () {

@@ -138,3 +194,23 @@ var count = 0;

});
});
it('should retry four times after an error and succeed', function () {
var count = 0;
return polly
.retry(5)
.executeForPromise(function () {
return new Promise(function (resolve, reject) {
count++;
if (count < 5) {
reject(new Error("Wrong value"));
} else {
resolve(42);
}
});
})
.should.eventually.equal(42)
.then(function () {
count.should.equal(5);
});
});

@@ -141,0 +217,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc