timers-browserify-full
This module is based on the original source files of node v0.12.0. This means that it is as compatible to node as possible, and it also uses linked lists like node. But it also means that it is quite heavy, and not necessary for most browserify projects. If you don't heavily use timers, the timers-browserify module, which is already integrated in browserify, is probably better suited.
Size: 1.73KB gzipped (4.45KB uncompressed)
install / usage with browserify
npm install timers-browserify-full
To use it with browserify, you have to use the js API of browserify; the command line API does not support changing builtins.
Example:
var browserify = ; var builtins = ;builtinstimers = require; var b = ; b
The above example will use timers-browserify-full for all browserify builds. If you only want it for a specific build of a larger build script:
var browserify = ; var builtins = ;var myBuiltins = {};Object; myBuiltinstimers = require var b = ; b
globals
In node, the functions setTimeout, clearTimeout, setInterval, clearInterval, setImmediate & clearImmediate are added to the global namespace. I don't recommend doing this in the browser, because it overrides the native functions. But you can use the following snippet inside your modules — this doesn't touch the global namespace:
var timers = ; var setTimeout = timerssetTimeout clearTimeout = timersclearTimeout setInterval = timerssetInterval clearInterval = timersclearInterval setImmediate = timerssetImmediate clearImmediate = timersclearImmediate;
credit
The two main files, timers.js and _linklist.js, are of course based on joyent/node; the _linklist.js file is even untouched!
The two scripts in bin
are borrowed from feross/buffer with modifications.
license
MIT