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.4.1 to 1.5.0

9

dist/lib/promise-poller.js

@@ -70,4 +70,11 @@ 'use strict';

function poll() {
var taskPromise = _bluebird2.default.resolve(options.taskFn());
var task = options.taskFn();
if (task === false) {
task = _bluebird2.default.reject('Cancelled');
retriesRemaining = 1;
}
var taskPromise = _bluebird2.default.resolve(task);
if (options.timeout) {

@@ -74,0 +81,0 @@ taskPromise = taskPromise.timeout(options.timeout);

@@ -241,2 +241,23 @@ 'use strict';

});
it('rejects the master promise if false is returned from the task function', function (done) {
var counter = 0;
var taskFn = function taskFn() {
if (++counter === 1) {
return false;
} else {
return _bluebird2.default.reject('derp');
}
};
(0, _promisePoller2.default)({
taskFn: taskFn,
interval: 500,
retries: 3
}).then(fail, function (err) {
expect(err).toEqual(['Cancelled']);
expect(counter).toEqual(1);
done();
});
});
});

4

package.json
{
"name": "promise-poller",
"version": "1.4.1",
"version": "1.5.0",
"description": "A basic poller built on top of promises",

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

"devDependencies": {
"babel-cli": "^6.11.4",
"babel-eslint": "^6.0.0",
"babel-preset-es2015": "^6.5.0",
"eslint": "^2.1.0",
"jasmine": "^2.4.1",
"jasmine-core": "^2.4.1"

@@ -39,0 +41,0 @@ },

@@ -68,2 +68,5 @@ # promise-poller

## Cancel polling
You may want to cancel the polling early. For example, if the poll fails because of an invalid password, that's not likely to change, so it would be a waste of time to continue to poll. To cancel polling early, return `false` from the task function instead of a promise.
## Select polling strategy

@@ -70,0 +73,0 @@ By default, `promise-poller` will use a fixed interval between each poll attempt. For example, with an `interval` option of 500, the poller will poll approximately every 500 milliseconds. This is the `fixed-interval` strategy. There are two other strategies available that may better suit your use case. To select a polling strategy, specify the `strategy` option, e.g.:

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