can-queues
Advanced tools
Comparing version 0.2.7 to 0.2.8
{ | ||
"name": "can-queues", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "A light weight JavaScript task queue", | ||
@@ -5,0 +5,0 @@ "homepage": "", |
11
queue.js
var queueState = require("./queue-state"); | ||
var canDev = require('can-util/js/dev/dev'); | ||
var noop = function() {}; | ||
function noOperation() {}; | ||
var Queue = function(name, callbacks) { | ||
this.callbacks = Object.assign({ | ||
onFirstTask: noop, | ||
onFirstTask: noOperation, | ||
// default clears the last task | ||
@@ -19,4 +19,5 @@ onComplete: function(){ | ||
}; | ||
Queue.noop = noOperation; | ||
Queue.prototype.enqueue = function(fn, context, args, meta) { | ||
this.tasks.push({ | ||
var len = this.tasks.push({ | ||
fn: fn, | ||
@@ -28,6 +29,6 @@ context: context, | ||
//!steal-remove-start | ||
this._logEnqueue(this.tasks[this.tasks.length - 1]); | ||
this._logEnqueue(this.tasks[len - 1]); | ||
//!steal-remove-end | ||
if (this.tasks.length === 1) { | ||
if (len === 1) { | ||
this.callbacks.onFirstTask(this); | ||
@@ -34,0 +35,0 @@ } |
30062
687
16