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.5.1 to 1.5.2

11

CHANGELOG.md
# Change Log
## 1.5.2 (January 9, 2017)
* Fixed the master timeout so that it doesn't make the program hang. Contributed by Jason Stitt.
## 1.5.1 (October 6, 2016)
* Fixed the master timeout so that it fires properly and no subsequent polls are made.
## 1.5.0 (August 17, 2016)
* Added feature to reject the master promise if the task function returns false
## 1.4.0 (April 21, 2016)

@@ -4,0 +15,0 @@

10

dist/lib/promise-poller.js

@@ -63,6 +63,7 @@ 'use strict';

var rejections = [];
var timeoutId = null;
if (options.masterTimeout) {
debug('(' + options.name + ') Using master timeout of ' + options.masterTimeout + ' ms.');
setTimeout(function () {
timeoutId = setTimeout(function () {
debug('(' + options.name + ') Master timeout reached. Rejecting master promise.');

@@ -79,3 +80,5 @@ polling = false;

task = _bluebird2.default.reject('Cancelled');
retriesRemaining = 1;
debug('(' + options.name + ') Task function returned false, canceling.');
reject(rejections);
polling = false;
}

@@ -91,2 +94,5 @@

debug('(' + options.name + ') Poll succeeded. Resolving master promise.');
if (timeoutId !== null) {
clearTimeout(timeoutId);
}
resolve(result);

@@ -93,0 +99,0 @@ }, function (err) {

@@ -262,2 +262,21 @@ 'use strict';

});
it('clears the master timeout if the master promise resolves', function (done) {
var globalObj = jasmine.getGlobal();
spyOn(globalObj, 'setTimeout').and.callFake(function () {
return 42;
});
spyOn(globalObj, 'clearTimeout');
(0, _promisePoller2.default)({
taskFn: function taskFn() {
return _bluebird2.default.resolve('foobar');
},
masterTimeout: 10000
}).then(function (val) {
expect(val).toEqual('foobar');
expect(globalObj.setTimeout).toHaveBeenCalled();
expect(globalObj.clearTimeout).toHaveBeenCalledWith(42);
done();
});
});
});

6

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

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

"babel-cli": "^6.11.4",
"babel-eslint": "^6.0.0",
"babel-eslint": "^7.0.0",
"babel-preset-es2015": "^6.5.0",
"eslint": "^2.1.0",
"eslint": "^3.7.1",
"jasmine": "^2.4.1",

@@ -40,0 +40,0 @@ "jasmine-core": "^2.4.1"

@@ -132,2 +132,3 @@ # promise-poller

* /u/jcready
* Jason Stitt

@@ -134,0 +135,0 @@ # License

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