1.1.0 • Published 9 years ago

browser-next-tick v1.1.0

Weekly downloads
188
License
ICS
Repository
github
Last release
9 years ago

process.nextTick for the browser

This can be used as either a process.nextTick implementation or a window.requestAnimationFrame polyfill.

Usage:

var nextTick = require('browser-next-tick');

nextTick(function() {
	// Will be run on next available event loop
});

Actual source:

module.exports = (function(window, prefixes, i, p, fnc) {
    while (!fnc && i < prefixes.length) {
        fnc = window[prefixes[i++] + 'equestAnimationFrame'];
    }
    return (fnc && fnc.bind(window)) || window.setImmediate || function(fnc) {window.setTimeout(fnc, 0);};
})(window, 'r webkitR mozR msR oR'.split(' '), 0);