Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rerun

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rerun - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

package.json
{
"name": "rerun",
"description": "A retry library for node.js",
"version": "1.0.0",
"version": "1.0.1",
"author": "BigPanda <noam@bigpanda.io>",

@@ -27,3 +27,5 @@ "repository": {

},
"publishConfig": { "registry": "https://registry.npmjs.org" },
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"devDependencies": {

@@ -30,0 +32,0 @@ "nock": "~0.27.2",

var Q = require('q');
var RejectError = require('./error/reject');

@@ -9,3 +10,3 @@ module.exports = function (toRetry, options) {

var factor = options.retryFactor || 1;
var RejectError = options.rejectError || require('./error/reject');
var userRejectError = options.rejectError || RejectError;

@@ -17,3 +18,3 @@ function _succeed(returned) {

function _failed(error) {
if (error instanceof RejectError || --retries <= 0) {
if (error instanceof RejectError || error instanceof userRejectError || --retries <= 0) {
deferred.reject(error);

@@ -20,0 +21,0 @@ } else {

@@ -61,2 +61,39 @@ var chai = require('chai');

});
it('should not retry even if rejecterror is defined weird', function (done) {
var id = { complicated: 'id' };
var data = [
{ foo: 'bar' }
];
var array = [
{ id: id, data: data }
];
var scope = nock('http://localhost:3027').post('/test', JSON.stringify({ objects: array })).reply(400);
var promise = request({ url: 'http://localhost:3027/test', json: { objects: array }, retries: 3, method: 'POST', rejectError: undefined });
promise.then(function () {
done(new Error('Should fail'));
}, function () {
scope.done();
done();
});
});
it('should not retry even if rejecterror is defined', function (done) {
var id = { complicated: 'id' };
var data = [
{ foo: 'bar' }
];
var array = [
{ id: id, data: data }
];
var scope = nock('http://localhost:3027').post('/test', JSON.stringify({ objects: array })).reply(400);
var promise = request({ url: 'http://localhost:3027/test', json: { objects: array }, retries: 3, method: 'POST', rejectError: require('../../src/promise') });
promise.then(function () {
done(new Error('Should fail'));
}, function () {
scope.done();
done();
});
});
it('should wait exponential time', function (done) {

@@ -63,0 +100,0 @@ var id = { complicated: 'id' };

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