Last active
August 29, 2015 14:00
-
-
Save rhoot/e075b19acf8e6d6b2259 to your computer and use it in GitHub Desktop.
Revisions
-
rhoot revised this gist
Apr 30, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ // Note: You probably do not want to use this in production code, as Promise is // not supported by all browsers yet. (function() { "use strict"; -
rhoot revised this gist
Apr 30, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,6 +30,8 @@ new Promise(function(resolve) { resolve(handle); }).then(onResolve); return handle; }; window.clearImmediate = function(handle) { -
rhoot created this gist
Apr 30, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ (function() { "use strict"; if (window.setImmediate) { return; } var pending = {}, nextHandle = 1; function onResolve(handle) { var callback = pending[handle]; if (callback) { delete pending[handle]; callback.fn.apply(null, callback.args); } } window.setImmediate = function(fn) { var args = Array.prototype.slice.call(arguments, 1), handle; if (typeof fn !== "function") { throw new TypeError("invalid function"); } handle = nextHandle++; pending[handle] = { fn: fn, args: args }; new Promise(function(resolve) { resolve(handle); }).then(onResolve); }; window.clearImmediate = function(handle) { delete pending[handle]; }; }());