From b38752f70d145af53a45bc8c05c27667c823235b Mon Sep 17 00:00:00 2001 From: cherif BOUCHELAGHEM Date: Wed, 27 Jun 2018 23:12:28 +0100 Subject: [PATCH] fix dev code for webpack compatibility --- completion-queue.js | 4 +++- priority-queue.js | 12 +++++++--- queue.js | 53 +++++++++++++++++++++++++-------------------- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/completion-queue.js b/completion-queue.js index 9fff373..72601b6 100644 --- a/completion-queue.js +++ b/completion-queue.js @@ -14,7 +14,9 @@ CompletionQueue.prototype.flush = function () { while ( this.index < this.tasks.length ) { var task = this.tasks[this.index++]; //!steal-remove-start - this._logFlush( task ); + if (process.env.NODE_ENV !== 'production') { + this._logFlush( task ); + } //!steal-remove-end task.fn.apply( task.context, task.args ); } diff --git a/priority-queue.js b/priority-queue.js index 81efe32..0248f70 100644 --- a/priority-queue.js +++ b/priority-queue.js @@ -49,7 +49,9 @@ PriorityQueue.prototype.enqueue = function ( fn, context, args, meta ) { this.taskMap.set( fn, task ); //!steal-remove-start - this._logEnqueue( task ); + if(process.env.NODE_ENV !== 'production') { + this._logEnqueue( task ); + } //!steal-remove-end if ( isFirst ) { @@ -97,7 +99,9 @@ PriorityQueue.prototype.flush = function () { // Run the task. var task = taskContainer.tasks[taskContainer.index++]; //!steal-remove-start - this._logFlush( task ); + if(process.env.NODE_ENV !== 'production') { + this._logFlush( task ); + } //!steal-remove-end this.tasksRemaining--; this.taskMap["delete"]( task.fn ); @@ -128,7 +132,9 @@ PriorityQueue.prototype.flushQueuedTask = function ( fn ) { var task = this.dequeue(fn); if(task) { //!steal-remove-start - this._logFlush( task ); + if(process.env.NODE_ENV !== 'production') { + this._logFlush( task ); + } //!steal-remove-end task.fn.apply( task.context, task.args ); } diff --git a/queue.js b/queue.js index 24773ad..5b8ccfb 100644 --- a/queue.js +++ b/queue.js @@ -31,7 +31,9 @@ Queue.prototype.enqueue = function ( fn, context, args, meta ) { meta: meta || {} }); //!steal-remove-start - this._logEnqueue( this.tasks[len - 1] ); + if(process.env.NODE_ENV !== 'production') { + this._logEnqueue( this.tasks[len - 1] ); + } //!steal-remove-end if ( len === 1 ) { @@ -43,7 +45,10 @@ Queue.prototype.flush = function () { while ( this.index < this.tasks.length ) { var task = this.tasks[this.index++]; //!steal-remove-start - this._logFlush( task ); + if(process.env.NODE_ENV !== 'production') { + this._logFlush( task ); + } + //!steal-remove-end task.fn.apply( task.context, task.args ); } @@ -58,28 +63,30 @@ Queue.prototype.log = function () { //The following are removed in production. //!steal-remove-start -Queue.prototype._logEnqueue = function ( task ) { - // For debugging, set the parentTask to the last - // run task. - task.meta.parentTask = queueState.lastTask; - // Also let the task know which stack it was run within. - task.meta.stack = this; +if(process.env.NODE_ENV !== 'production') { + Queue.prototype._logEnqueue = function ( task ) { + // For debugging, set the parentTask to the last + // run task. + task.meta.parentTask = queueState.lastTask; + // Also let the task know which stack it was run within. + task.meta.stack = this; - if ( this._log === true || this._log === "enqueue" ) { - var log = task.meta.log ? task.meta.log.concat( task ) : [task.fn.name, task]; - canDev.log.apply( canDev, [this.name + " enqueuing:"].concat( log )); - } -}; -// `_logFlush` MUST be called by all queues prior to flushing in -// development. -Queue.prototype._logFlush = function ( task ) { - if ( this._log === true || this._log === "flush" ) { - var log = task.meta.log ? task.meta.log.concat( task ) : [task.fn.name, task]; - canDev.log.apply( canDev, [this.name + " running :"].concat( log )); - } - // Update the state to mark this as the task that was run last. - queueState.lastTask = task; -}; + if ( this._log === true || this._log === "enqueue" ) { + var log = task.meta.log ? task.meta.log.concat( task ) : [task.fn.name, task]; + canDev.log.apply( canDev, [this.name + " enqueuing:"].concat( log )); + } + }; + // `_logFlush` MUST be called by all queues prior to flushing in + // development. + Queue.prototype._logFlush = function ( task ) { + if ( this._log === true || this._log === "flush" ) { + var log = task.meta.log ? task.meta.log.concat( task ) : [task.fn.name, task]; + canDev.log.apply( canDev, [this.name + " running :"].concat( log )); + } + // Update the state to mark this as the task that was run last. + queueState.lastTask = task; + }; +} //!steal-remove-end module.exports = Queue;