Skip to content

Commit

Permalink
added internal ._isEnded() method
Browse files Browse the repository at this point in the history
  • Loading branch information
lfortin committed Jan 22, 2015
1 parent 7560d57 commit ec90168
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions os-monitor.js
Expand Up @@ -90,7 +90,7 @@ Monitor.prototype.start = function(options) {

var self = this;

if(this._monitorState.ended) {
if(this._isEnded()) {
throw new Error("monitor has been ended by .destroy() method");
}

Expand Down Expand Up @@ -160,7 +160,7 @@ Monitor.prototype.reset = function() {

Monitor.prototype.destroy = function() {

if(!this._monitorState.ended) {
if(!this._isEnded()) {
this.sendEvent('destroy', {type: 'destroy'});
this.stop();
if(this instanceof stream.Readable) {
Expand Down Expand Up @@ -190,6 +190,10 @@ Monitor.prototype.isRunning = function() {
return !!this._monitorState.running;
};

Monitor.prototype._isEnded = function() {
return !!this._monitorState.ended;
};

Monitor.prototype.throttle = function(event, handler, wait) {
var self = this,
_handler = _.wrap(handler, function(fn) {
Expand Down

0 comments on commit ec90168

Please sign in to comment.