Comparing version 3.2.0 to 3.2.1
{ | ||
"name": "immediate", | ||
"version": "3.0.2", | ||
"version": "3.2.1", | ||
"description": "A cross browser microtask library", | ||
@@ -13,2 +13,2 @@ "homepage": "https://github.com/calvinmetcalf/immediate", | ||
"main": "dist/immediate.js" | ||
} | ||
} |
{ | ||
"name": "immediate", | ||
"version": "3.0.2", | ||
"version": "3.2.1", | ||
"description": "A cross browser microtask library", | ||
@@ -13,2 +13,2 @@ "repo": "calvinmetcalf/immediate", | ||
] | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.immediate=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(_dereq_,module,exports){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.immediate = f()}})(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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -11,18 +11,36 @@ var types = [ | ||
var draining; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
var queue = []; | ||
var scheduled = false; | ||
function cleanUpNextTick() { | ||
draining = false; | ||
if (currentQueue && currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
nextTick(); | ||
} | ||
} | ||
//named nextTick for less confusing stack traces | ||
function nextTick() { | ||
scheduled = false; | ||
draining = true; | ||
var i, oldQueue; | ||
var len = queue.length; | ||
var timeout = setTimeout(cleanUpNextTick); | ||
while (len) { | ||
oldQueue = queue; | ||
currentQueue = queue; | ||
queue = []; | ||
i = -1; | ||
while (++i < len) { | ||
oldQueue[i](); | ||
while (++queueIndex < len) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
queueIndex = -1; | ||
draining = false; | ||
clearTimeout(timeout); | ||
} | ||
@@ -32,3 +50,3 @@ var scheduleDrain; | ||
var len = types.length; | ||
while (++ i < len) { | ||
while (++i < len) { | ||
if (types[i] && types[i].test && types[i].test()) { | ||
@@ -39,8 +57,25 @@ scheduleDrain = types[i].install(nextTick); | ||
} | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
module.exports = immediate; | ||
function immediate(task) { | ||
if (queue.push(task) === 1 && !draining) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(task, args)); | ||
if (!scheduled && !draining) { | ||
scheduled = true; | ||
scheduleDrain(); | ||
} | ||
} | ||
},{"./messageChannel":2,"./mutation.js":3,"./nextTick":6,"./stateChange":4,"./timeout":5}],2:[function(_dereq_,module,exports){ | ||
@@ -66,3 +101,3 @@ (function (global){ | ||
}; | ||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],3:[function(_dereq_,module,exports){ | ||
@@ -92,3 +127,3 @@ (function (global){ | ||
}; | ||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],4:[function(_dereq_,module,exports){ | ||
@@ -120,3 +155,3 @@ (function (global){ | ||
}; | ||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],5:[function(_dereq_,module,exports){ | ||
@@ -135,4 +170,3 @@ 'use strict'; | ||
},{}]},{},[1]) | ||
(1) | ||
}); | ||
},{}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.immediate=e()}}(function(){return function e(n,t,o){function i(u,f){if(!t[u]){if(!n[u]){var s="function"==typeof require&&require;if(!f&&s)return s(u,!0);if(r)return r(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=t[u]={exports:{}};n[u][0].call(a.exports,function(e){var t=n[u][1][e];return i(t?t:e)},a,a.exports,e,n,t,o)}return t[u].exports}for(var r="function"==typeof require&&require,u=0;u<o.length;u++)i(o[u]);return i}({1:[function(e,n){"use strict";function t(){i=!0;for(var e,n,t=f.length;t;){for(n=f,f=[],e=-1;++e<t;)n[e]();t=f.length}i=!1}function o(e){1!==f.push(e)||i||r()}for(var i,r,u=[e("./nextTick"),e("./mutation.js"),e("./messageChannel"),e("./stateChange"),e("./timeout")],f=[],s=-1,a=u.length;++s<a;)if(u[s]&&u[s].test&&u[s].test()){r=u[s].install(t);break}n.exports=o},{"./messageChannel":2,"./mutation.js":3,"./nextTick":6,"./stateChange":4,"./timeout":5}],2:[function(e,n,t){(function(e){"use strict";t.test=function(){return e.setImmediate?!1:"undefined"!=typeof e.MessageChannel},t.install=function(n){var t=new e.MessageChannel;return t.port1.onmessage=n,function(){t.port2.postMessage(0)}}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,n,t){(function(e){"use strict";var n=e.MutationObserver||e.WebKitMutationObserver;t.test=function(){return n},t.install=function(t){var o=0,i=new n(t),r=e.document.createTextNode("");return i.observe(r,{characterData:!0}),function(){r.data=o=++o%2}}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,n,t){(function(e){"use strict";t.test=function(){return"document"in e&&"onreadystatechange"in e.document.createElement("script")},t.install=function(n){return function(){var t=e.document.createElement("script");return t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t),n}}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(e,n,t){"use strict";t.test=function(){return!0},t.install=function(e){return function(){setTimeout(e,0)}}},{}],6:[function(){},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.immediate=e()}}(function(){return function e(n,t,o){function i(u,f){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(r)return r(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return i(t?t:e)},l,l.exports,e,n,t,o)}return t[u].exports}for(var r="function"==typeof require&&require,u=0;u<o.length;u++)i(o[u]);return i}({1:[function(e,n,t){"use strict";function o(){f=!1,a&&a.length?d=a.concat(d):c=-1,d.length&&i()}function i(){p=!1,f=!0;for(var e=d.length,n=setTimeout(o);e;){for(a=d,d=[];++c<e;)a[c].run();c=-1,e=d.length}c=-1,f=!1,clearTimeout(n)}function r(e,n){this.fun=e,this.array=n}function u(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];d.push(new r(e,n)),p||f||(p=!0,s())}for(var f,a,s,l=[e("./nextTick"),e("./mutation.js"),e("./messageChannel"),e("./stateChange"),e("./timeout")],c=-1,d=[],p=!1,g=-1,m=l.length;++g<m;)if(l[g]&&l[g].test&&l[g].test()){s=l[g].install(i);break}r.prototype.run=function(){this.fun.apply(null,this.array)},n.exports=u},{"./messageChannel":2,"./mutation.js":3,"./nextTick":6,"./stateChange":4,"./timeout":5}],2:[function(e,n,t){(function(e){"use strict";t.test=function(){return e.setImmediate?!1:"undefined"!=typeof e.MessageChannel},t.install=function(n){var t=new e.MessageChannel;return t.port1.onmessage=n,function(){t.port2.postMessage(0)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,n,t){(function(e){"use strict";var n=e.MutationObserver||e.WebKitMutationObserver;t.test=function(){return n},t.install=function(t){var o=0,i=new n(t),r=e.document.createTextNode("");return i.observe(r,{characterData:!0}),function(){r.data=o=++o%2}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,n,t){(function(e){"use strict";t.test=function(){return"document"in e&&"onreadystatechange"in e.document.createElement("script")},t.install=function(n){return function(){var t=e.document.createElement("script");return t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t),n}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(e,n,t){"use strict";t.test=function(){return!0},t.install=function(e){return function(){setTimeout(e,0)}}},{}],6:[function(e,n,t){},{}]},{},[1])(1)}); |
{ | ||
"name": "immediate", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "A cross browser microtask library", | ||
@@ -37,15 +37,13 @@ "contributors": [ | ||
"uglify": "uglifyjs dist/immediate.js -mc > dist/immediate.min.js", | ||
"build-js": "browserify -s immediate ./lib/index.js > dist/immediate.js", | ||
"build-js": "browserify -s immediate ./lib/index.js | derequire > dist/immediate.js", | ||
"test": "jshint lib/*.js && node test/tests.js | tspec" | ||
}, | ||
"jam": { | ||
"main": "dist/immediate.js" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^4.1.5", | ||
"browserify": "^10.0.0", | ||
"derequire": "^2.0.0", | ||
"jshint": "^2.5.1", | ||
"tap-spec": "^3.0.0", | ||
"uglify-js": "^2.4.13", | ||
"tape": "^4.0.0" | ||
"tape": "^4.0.0", | ||
"uglify-js": "^2.4.13" | ||
} | ||
} |
@@ -31,4 +31,6 @@ # immediate [![Build Status](https://travis-ci.org/calvinmetcalf/immediate.svg?branch=master)](https://travis-ci.org/calvinmetcalf/immediate) | ||
Several new features were added in versions 3.1.0 and 3.2.0 to maintain parity with | ||
process.nextTick, but the 3.0.x series is still being kept up to date if you just need | ||
the small barebones version | ||
## The Tricks | ||
@@ -35,0 +37,0 @@ |
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
19022
334
82
6