polyfills.setImmediate.min.js Maven / Gradle / Ivy
The newest version!
!function(e,t){"use strict";function n(e){return c[i]=a.apply(t,e),i++}function a(e){var n=[].slice.call(arguments,1);return function(){"function"==typeof e?e.apply(t,n):new Function(""+e)()}}function o(e){if(u)setTimeout(a(o,e),0);else{var t=c[e];if(t){u=!0;try{t()}finally{s(e),u=!1}}}}function s(e){delete c[e]}if(!e.setImmediate){var r,i=1,c={},u=!1,f=e.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(e);l=l&&l.setTimeout?l:e,"[object process]"==={}.toString.call(e.process)?function(){r=function(){var e=n(arguments);return process.nextTick(a(o,e)),e}}():function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?function(){var t="setImmediate$"+Math.random()+"$",a=function(n){n.source===e&&"string"==typeof n.data&&0===n.data.indexOf(t)&&o(+n.data.slice(t.length))};e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),r=function(){var a=n(arguments);return e.postMessage(t+a,"*"),a}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){o(e.data)},r=function(){var t=n(arguments);return e.port2.postMessage(t),t}}():f&&"onreadystatechange"in f.createElement("script")?function(){var e=f.documentElement;r=function(){var t=n(arguments),a=f.createElement("script");return a.onreadystatechange=function(){o(t),a.onreadystatechange=null,e.removeChild(a),a=null},e.appendChild(a),t}}():function(){r=function(){var e=n(arguments);return setTimeout(a(o,e),0),e}}(),l.setImmediate=r,l.clearImmediate=s}}(this);