Skip to content

Commit 40d9cf0

Browse files
author
Tobiah
committed
fix: delay start no longer force a new update with getData
1 parent e7457a8 commit 40d9cf0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jsoncache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JSONCache extends EventEmitter {
3535
* @param {number} options.maxRetry maximum number of attempts to retry getting data
3636
* @param {function} options.integrity optional function to check if the data is worth keeping
3737
*/
38-
constructor(url, timeout = 60000, options) {
38+
constructor(url, timeout, options) {
3939
super();
4040

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

5353
this.maxRetry = maxRetry;
54-
this.timeout = timeout;
54+
this.timeout = timeout || 60000;
5555
this.currentData = null;
5656
this.updating = null;
5757
this.Promise = promiseLib;
@@ -71,7 +71,7 @@ class JSONCache extends EventEmitter {
7171
}
7272

7373
getData() {
74-
if (this.delayStart) {
74+
if (this.delayStart && !this.currentData && !this.updating) {
7575
this.startUpdating();
7676
}
7777
if (this.updating) {

0 commit comments

Comments
 (0)