Skip to content

Commit

Permalink
fix dev code for webpack compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cherif BOUCHELAGHEM committed Jun 27, 2018
1 parent 91da2d1 commit b38752f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
4 changes: 3 additions & 1 deletion completion-queue.js
Expand Up @@ -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 );
}
Expand Down
12 changes: 9 additions & 3 deletions priority-queue.js
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down
53 changes: 30 additions & 23 deletions queue.js
Expand Up @@ -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 ) {
Expand All @@ -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 );
}
Expand All @@ -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;

0 comments on commit b38752f

Please sign in to comment.