browser-next-tick

1.1.0 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i browser-next-tick

Weekly Downloads

8

Version

1.1.0

License

ICS

Last publish

Collaborators

  • wesleytodd