[Pkg-javascript-commits] [node-async] 201/480: Add async.nextTick browser fallback to setImmediate

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 4ef2984463de6fcc5685ebaf680db02a01587b97
Author: Douglas Christopher Wilson <doug at somethingdoug.com>
Date:   Tue Jun 12 15:16:08 2012 -0400

    Add async.nextTick browser fallback to setImmediate
    
    This adds the nextTick fallback for browsers to support
    the proposed setImmediate interface, which is similar
    to process.nextTick in browsers that support it, or on
    sites that implement a shim for setImmediate before
    loading async.
---
 README.md         |  5 +++--
 dist/async.min.js |  2 +-
 lib/async.js      | 15 +++++++++++----
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 1bbbc47..36ea01a 100644
--- a/README.md
+++ b/README.md
@@ -901,8 +901,9 @@ continuation:
 ### nextTick(callback)
 
 Calls the callback on a later loop around the event loop. In node.js this just
-calls process.nextTick, in the browser it falls back to setTimeout(callback, 0),
-which means other higher priority events may precede the execution of the callback.
+calls process.nextTick, in the browser it falls back to setImmediate(callback)
+if available, otherwise setTimeout(callback, 0), which means other higher priority
+events may precede the execution of the callback.
 
 This is used internally for browser-compatibility purposes.
 
diff --git a/dist/async.min.js b/dist/async.min.js
index 6ba3145..78aa10b 100644
--- a/dist/async.min.js
+++ b/dist/async.min.js
@@ -1 +1 @@
-/*global setTimeout: false, console: false */(function(){var a={},b=this,c=b.async;typeof module!="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){return b.async=c,a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)},e=function(a,b){if(a.map)return a.map(b);var c=[];return d(a,function(a,d,e){c.push(b(a,d,e))}),c},f=function(a,b,c){return a.reduce?a.reduce(b,c):(d(a,function(a,d,e){c=b(c,a,d,e)}),c)},g=function(a){ [...]
\ No newline at end of file
+/*global setImmediate: false, setTimeout: false, console: false */(function(){var e={},t=this,n=t.async;typeof module!="undefined"&&module.exports?module.exports=e:t.async=e,e.noConflict=function(){return t.async=n,e};var r=function(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n+=1)t(e[n],n,e)},i=function(e,t){if(e.map)return e.map(t);var n=[];return r(e,function(e,r,i){n.push(t(e,r,i))}),n},s=function(e,t,n){return e.reduce?e.reduce(t,n):(r(e,function(e,r,i){n=t(n,e,r,i) [...]
\ No newline at end of file
diff --git a/lib/async.js b/lib/async.js
index 7cc4f5e..9ead599 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -1,4 +1,4 @@
-/*global setTimeout: false, console: false */
+/*global setImmediate: false, setTimeout: false, console: false */
 (function () {
 
     var async = {};
@@ -68,9 +68,16 @@
 
     //// nextTick implementation with browser-compatible fallback ////
     if (typeof process === 'undefined' || !(process.nextTick)) {
-        async.nextTick = function (fn) {
-            setTimeout(fn, 0);
-        };
+        if (typeof setImmediate === 'function') {
+            async.nextTick = function (fn) {
+                setImmediate(fn);
+            };
+        }
+        else {
+            async.nextTick = function (fn) {
+                setTimeout(fn, 0);
+            };
+        }
     }
     else {
         async.nextTick = process.nextTick;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list