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

promise-poller

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-poller - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

8

CHANGELOG.md
# Change Log
## 1.3.0 (March 22, 2016)
* Changed master promise rejection to include all errors from all poll rejections.
## 1.2.0 (March 12, 2016)
* Added timeout support.
## 1.1.0 (March 5, 2016)

@@ -4,0 +12,0 @@

4

dist/lib/promise-poller.js

@@ -56,2 +56,3 @@ 'use strict';

var retriesRemaining = options.retries;
var rejections = [];
function poll() {

@@ -66,2 +67,3 @@ var taskPromise = _bluebird2.default.resolve(options.taskFn());

}, function (err) {
rejections.push(err);
if (typeof options.progressCallback === 'function') {

@@ -73,3 +75,3 @@ options.progressCallback(retriesRemaining, err);

debug('(' + options.name + ') Maximum retries reached. Rejecting master promise.');
reject(err);
reject(rejections);
} else {

@@ -76,0 +78,0 @@ debug('(' + options.name + ') Poll failed. ' + retriesRemaining + ' retries remaining.');

@@ -51,3 +51,2 @@ 'use strict';

}, function (err) {
expect(err).toBe('derp');
done();

@@ -57,2 +56,18 @@ });

it('rejects the master promise with an array of rejections', function (done) {
var counter = 0;
(0, _promisePoller2.default)({
taskFn: function taskFn() {
return _bluebird2.default.reject(++counter);
},
interval: 500,
retries: 3
}).then(function () {
return fail('Promise was resolved');
}, function (errs) {
expect(errs).toEqual([1, 2, 3]);
done();
});
});
it('fails the poll if the timeout is exceeded', function (done) {

@@ -76,3 +91,3 @@ var taskFn = function taskFn() {

}, function (error) {
expect(error.message.indexOf('timed out')).not.toBeLessThan(0);
expect(error[2].message.indexOf('timed out')).not.toBeLessThan(0);
done();

@@ -79,0 +94,0 @@ });

{
"name": "promise-poller",
"version": "1.2.0",
"version": "1.3.0",
"description": "A basic poller built on top of promises",

@@ -5,0 +5,0 @@ "main": "dist/lib/promise-poller.js",

@@ -27,3 +27,3 @@ # promise-poller

The master promise will be resolved with the value that your task promise is resolved with. Similarly, the master promise will be rejected with the *last failure*.
The master promise will be resolved with the value that your task promise is resolved with. If the poll fails, the master promise will be rejected with an array of all the rejection reasons for each poll attempt.

@@ -30,0 +30,0 @@ `promise-poller` will attempt your task by calling the function and waiting on the returned promise. If the promise is rejected, `promise-poller` will wait one second and try again. It will attempt to execute your task 3 times before rejecting the master promise.

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