Skip to content

Commit

Permalink
Check for heartbeat before referencing it
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Grondin committed Jul 6, 2019
1 parent d5d353b commit 5978fdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -4359,13 +4359,13 @@
}.call(this);

this._queues.on("leftzero", function () {
var base;
return typeof (base = _this._store.heartbeat).ref === "function" ? base.ref() : void 0;
var ref;
return (ref = _this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
});

this._queues.on("zero", function () {
var base;
return typeof (base = _this._store.heartbeat).unref === "function" ? base.unref() : void 0;
var ref;
return (ref = _this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
});
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Bottleneck.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Bottleneck = function () {
}.call(this);

this._queues.on("leftzero", () => {
var base;
return typeof (base = this._store.heartbeat).ref === "function" ? base.ref() : void 0;
var ref;
return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
});

this._queues.on("zero", () => {
var base;
return typeof (base = this._store.heartbeat).unref === "function" ? base.unref() : void 0;
var ref;
return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
});
}

Expand Down
8 changes: 4 additions & 4 deletions light.js
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,12 @@
}
}).call(this);
this._queues.on("leftzero", () => {
var base;
return typeof (base = this._store.heartbeat).ref === "function" ? base.ref() : void 0;
var ref;
return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
});
this._queues.on("zero", () => {
var base;
return typeof (base = this._store.heartbeat).unref === "function" ? base.unref() : void 0;
var ref;
return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/Bottleneck.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class Bottleneck
else
throw new Bottleneck::BottleneckError "Invalid datastore type: #{@datastore}"

@_queues.on "leftzero", => @_store.heartbeat.ref?()
@_queues.on "zero", => @_store.heartbeat.unref?()
@_queues.on "leftzero", => @_store.heartbeat?.ref?()
@_queues.on "zero", => @_store.heartbeat?.unref?()

_validateOptions: (options, invalid) ->
unless options? and typeof options == "object" and invalid.length == 0
Expand Down

0 comments on commit 5978fdf

Please sign in to comment.