Comparing version 3.5.1 to 3.5.2
@@ -16,3 +16,3 @@ !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
},{"../lib/Promise":2,"../lib/decorators/unhandledRejection":5}],2:[function(require,module,exports){ | ||
},{"../lib/Promise":2,"../lib/decorators/unhandledRejection":4}],2:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
@@ -36,3 +36,3 @@ /** @author Brian Cavalier */ | ||
},{"./Scheduler":4,"./env":6,"./makePromise":7}],3:[function(require,module,exports){ | ||
},{"./Scheduler":3,"./env":5,"./makePromise":6}],3:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
@@ -44,77 +44,3 @@ /** @author Brian Cavalier */ | ||
define(function() { | ||
/** | ||
* Circular queue | ||
* @param {number} capacityPow2 power of 2 to which this queue's capacity | ||
* will be set initially. eg when capacityPow2 == 3, queue capacity | ||
* will be 8. | ||
* @constructor | ||
*/ | ||
function Queue(capacityPow2) { | ||
this.head = this.tail = this.length = 0; | ||
this.buffer = new Array(1 << capacityPow2); | ||
} | ||
Queue.prototype.push = function(x) { | ||
if(this.length === this.buffer.length) { | ||
this._ensureCapacity(this.length * 2); | ||
} | ||
this.buffer[this.tail] = x; | ||
this.tail = (this.tail + 1) & (this.buffer.length - 1); | ||
++this.length; | ||
return this.length; | ||
}; | ||
Queue.prototype.shift = function() { | ||
var x = this.buffer[this.head]; | ||
this.buffer[this.head] = void 0; | ||
this.head = (this.head + 1) & (this.buffer.length - 1); | ||
--this.length; | ||
return x; | ||
}; | ||
Queue.prototype._ensureCapacity = function(capacity) { | ||
var head = this.head; | ||
var buffer = this.buffer; | ||
var newBuffer = new Array(capacity); | ||
var i = 0; | ||
var len; | ||
if(head === 0) { | ||
len = this.length; | ||
for(; i<len; ++i) { | ||
newBuffer[i] = buffer[i]; | ||
} | ||
} else { | ||
capacity = buffer.length; | ||
len = this.tail; | ||
for(; head<capacity; ++i, ++head) { | ||
newBuffer[i] = buffer[head]; | ||
} | ||
for(head=0; head<len; ++i, ++head) { | ||
newBuffer[i] = buffer[head]; | ||
} | ||
} | ||
this.buffer = newBuffer; | ||
this.head = 0; | ||
this.tail = this.length; | ||
}; | ||
return Queue; | ||
}); | ||
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); | ||
},{}],4:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
/** @author Brian Cavalier */ | ||
/** @author John Hann */ | ||
(function(define) { 'use strict'; | ||
define(function(require) { | ||
var Queue = require('./Queue'); | ||
// Credit to Twisol (https://github.com/Twisol) for suggesting | ||
@@ -130,6 +56,9 @@ // this type of extensible queue + trampoline approach for next-tick conflation. | ||
this._async = async; | ||
this._queue = new Queue(15); | ||
this._afterQueue = new Queue(5); | ||
this._running = false; | ||
this._queue = new Array(1<<16); | ||
this._queueLen = 0; | ||
this._afterQueue = new Array(1<<4); | ||
this._afterQueueLen = 0; | ||
var self = this; | ||
@@ -146,3 +75,4 @@ this.drain = function() { | ||
Scheduler.prototype.enqueue = function(task) { | ||
this._add(this._queue, task); | ||
this._queue[this._queueLen++] = task; | ||
this.run(); | ||
}; | ||
@@ -155,5 +85,13 @@ | ||
Scheduler.prototype.afterQueue = function(task) { | ||
this._add(this._afterQueue, task); | ||
this._afterQueue[this._afterQueueLen++] = task; | ||
this.run(); | ||
}; | ||
Scheduler.prototype.run = function() { | ||
if (!this._running) { | ||
this._running = true; | ||
this._async(this.drain); | ||
} | ||
}; | ||
/** | ||
@@ -163,37 +101,25 @@ * Drain the handler queue entirely, and then the after queue | ||
Scheduler.prototype._drain = function() { | ||
runQueue(this._queue); | ||
var i = 0; | ||
for (; i < this._queueLen; ++i) { | ||
this._queue[i].run(); | ||
this._queue[i] = void 0; | ||
} | ||
this._queueLen = 0; | ||
this._running = false; | ||
runQueue(this._afterQueue); | ||
}; | ||
/** | ||
* Add a task to the q, and schedule drain if not already scheduled | ||
* @param {Queue} queue | ||
* @param {{run:function}} task | ||
* @private | ||
*/ | ||
Scheduler.prototype._add = function(queue, task) { | ||
queue.push(task); | ||
if(!this._running) { | ||
this._running = true; | ||
this._async(this.drain); | ||
for (i = 0; i < this._afterQueueLen; ++i) { | ||
this._afterQueue[i].run(); | ||
this._afterQueue[i] = void 0; | ||
} | ||
this._afterQueueLen = 0; | ||
}; | ||
/** | ||
* Run all the tasks in the q | ||
* @param queue | ||
*/ | ||
function runQueue(queue) { | ||
while(queue.length > 0) { | ||
queue.shift().run(); | ||
} | ||
} | ||
return Scheduler; | ||
}); | ||
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); | ||
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); | ||
},{"./Queue":3}],5:[function(require,module,exports){ | ||
},{}],4:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
@@ -302,3 +228,3 @@ /** @author Brian Cavalier */ | ||
},{"../env":6}],6:[function(require,module,exports){ | ||
},{"../env":5}],5:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
@@ -378,3 +304,3 @@ /** @author Brian Cavalier */ | ||
},{}],7:[function(require,module,exports){ | ||
},{}],6:[function(require,module,exports){ | ||
/** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
@@ -381,0 +307,0 @@ /** @author Brian Cavalier */ |
@@ -36,3 +36,4 @@ /** @license MIT License (c) copyright 2013-2014 original author or authors */ | ||
function apply(f, args) { | ||
return _apply(f, this, args || []); | ||
// slice args just in case the caller passed an Arguments instance | ||
return _apply(f, this, args == null ? [] : slice.call(args)); | ||
} | ||
@@ -64,2 +65,3 @@ | ||
function _apply(f, thisArg, args) { | ||
// args MUST be an Array | ||
return args.length === 0 | ||
@@ -66,0 +68,0 @@ ? attempt.call(thisArg, f) |
@@ -13,11 +13,16 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
var logInfo = noop; | ||
var localConsole; | ||
if(typeof console !== 'undefined') { | ||
logError = typeof console.error !== 'undefined' | ||
? function (e) { console.error(e); } | ||
: function (e) { console.log(e); }; | ||
// Alias console to prevent things like uglify's drop_console option from | ||
// removing console.log/error. Unhandled rejections fall into the same | ||
// category as uncaught exceptions, and build tools shouldn't silence them. | ||
localConsole = console; | ||
logError = typeof localConsole.error !== 'undefined' | ||
? function (e) { localConsole.error(e); } | ||
: function (e) { localConsole.log(e); }; | ||
logInfo = typeof console.info !== 'undefined' | ||
? function (e) { console.info(e); } | ||
: function (e) { console.log(e); }; | ||
logInfo = typeof localConsole.info !== 'undefined' | ||
? function (e) { localConsole.info(e); } | ||
: function (e) { localConsole.log(e); }; | ||
} | ||
@@ -24,0 +29,0 @@ |
@@ -6,6 +6,4 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
(function(define) { 'use strict'; | ||
define(function(require) { | ||
define(function() { | ||
var Queue = require('./Queue'); | ||
// Credit to Twisol (https://github.com/Twisol) for suggesting | ||
@@ -21,6 +19,9 @@ // this type of extensible queue + trampoline approach for next-tick conflation. | ||
this._async = async; | ||
this._queue = new Queue(15); | ||
this._afterQueue = new Queue(5); | ||
this._running = false; | ||
this._queue = new Array(1<<16); | ||
this._queueLen = 0; | ||
this._afterQueue = new Array(1<<4); | ||
this._afterQueueLen = 0; | ||
var self = this; | ||
@@ -37,3 +38,4 @@ this.drain = function() { | ||
Scheduler.prototype.enqueue = function(task) { | ||
this._add(this._queue, task); | ||
this._queue[this._queueLen++] = task; | ||
this.run(); | ||
}; | ||
@@ -46,5 +48,13 @@ | ||
Scheduler.prototype.afterQueue = function(task) { | ||
this._add(this._afterQueue, task); | ||
this._afterQueue[this._afterQueueLen++] = task; | ||
this.run(); | ||
}; | ||
Scheduler.prototype.run = function() { | ||
if (!this._running) { | ||
this._running = true; | ||
this._async(this.drain); | ||
} | ||
}; | ||
/** | ||
@@ -54,34 +64,22 @@ * Drain the handler queue entirely, and then the after queue | ||
Scheduler.prototype._drain = function() { | ||
runQueue(this._queue); | ||
var i = 0; | ||
for (; i < this._queueLen; ++i) { | ||
this._queue[i].run(); | ||
this._queue[i] = void 0; | ||
} | ||
this._queueLen = 0; | ||
this._running = false; | ||
runQueue(this._afterQueue); | ||
}; | ||
/** | ||
* Add a task to the q, and schedule drain if not already scheduled | ||
* @param {Queue} queue | ||
* @param {{run:function}} task | ||
* @private | ||
*/ | ||
Scheduler.prototype._add = function(queue, task) { | ||
queue.push(task); | ||
if(!this._running) { | ||
this._running = true; | ||
this._async(this.drain); | ||
for (i = 0; i < this._afterQueueLen; ++i) { | ||
this._afterQueue[i].run(); | ||
this._afterQueue[i] = void 0; | ||
} | ||
this._afterQueueLen = 0; | ||
}; | ||
/** | ||
* Run all the tasks in the q | ||
* @param queue | ||
*/ | ||
function runQueue(queue) { | ||
while(queue.length > 0) { | ||
queue.shift().run(); | ||
} | ||
} | ||
return Scheduler; | ||
}); | ||
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); | ||
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); |
@@ -49,18 +49,22 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
} else { | ||
if(typeof console.error === 'function' | ||
&& typeof console.dir === 'function') { | ||
// Alias console to prevent things like uglify's drop_console option from | ||
// removing console.log/error. Unhandled rejections fall into the same | ||
// category as uncaught exceptions, and build tools shouldn't silence them. | ||
var localConsole = console; | ||
if(typeof localConsole.error === 'function' | ||
&& typeof localConsole.dir === 'function') { | ||
warn = function(s) { | ||
console.error(s); | ||
localConsole.error(s); | ||
}; | ||
log = function(s) { | ||
console.log(s); | ||
localConsole.log(s); | ||
}; | ||
if(typeof console.groupCollapsed === 'function') { | ||
if(typeof localConsole.groupCollapsed === 'function') { | ||
groupStart = function(s) { | ||
console.groupCollapsed(s); | ||
localConsole.groupCollapsed(s); | ||
}; | ||
groupEnd = function() { | ||
console.groupEnd(); | ||
localConsole.groupEnd(); | ||
}; | ||
@@ -72,3 +76,3 @@ } | ||
// Credit to webpro (https://github.com/webpro) for this idea | ||
if (typeof console.log ==='function' | ||
if (typeof localConsole.log ==='function' | ||
&& typeof JSON !== 'undefined') { | ||
@@ -81,3 +85,3 @@ log = warn = function (x) { | ||
} | ||
console.log(x); | ||
localConsole.log(x); | ||
}; | ||
@@ -84,0 +88,0 @@ } |
{ | ||
"name": "when", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "A lightweight Promises/A+ and when() implementation, plus other async goodies.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,3 +8,3 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */ | ||
* @author John Hann | ||
* @version 3.5.1 | ||
* @version 3.5.2 | ||
*/ | ||
@@ -11,0 +11,0 @@ (function(define) { 'use strict'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143164
44
4221