Comparing version 1.0.0 to 1.0.1
{ | ||
"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' }; |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17918
160
0