Skip to content

Commit

Permalink
fix: delay start no longer force a new update with getData
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobiah committed Feb 21, 2020
1 parent e7457a8 commit 40d9cf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jsoncache.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JSONCache extends EventEmitter {
* @param {number} options.maxRetry maximum number of attempts to retry getting data
* @param {function} options.integrity optional function to check if the data is worth keeping
*/
constructor(url, timeout = 60000, options) {
constructor(url, timeout, options) {
super();

// eslint-disable-next-line no-param-reassign
Expand All @@ -51,7 +51,7 @@ class JSONCache extends EventEmitter {
this.protocol = this.url.startsWith('https') ? require('https') : require('http');

this.maxRetry = maxRetry;
this.timeout = timeout;
this.timeout = timeout || 60000;
this.currentData = null;
this.updating = null;
this.Promise = promiseLib;
Expand All @@ -71,7 +71,7 @@ class JSONCache extends EventEmitter {
}

getData() {
if (this.delayStart) {
if (this.delayStart && !this.currentData && !this.updating) {
this.startUpdating();
}
if (this.updating) {
Expand Down

0 comments on commit 40d9cf0

Please sign in to comment.