timers module for browserify
Branch: master
Clone or download
Latest commit bedb529 Apr 18, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example/enroll Add example server May 30, 2012
.gitignore Update packaging May 30, 2012
.npmignore Add .npmignore. (#23) Oct 19, 2016
CHANGELOG.md Update CHANGELOG Apr 18, 2018
LICENSE.md Initial timers setup May 26, 2012
README.md Add section in README for timers-browserify-full Feb 14, 2015
main.js Try self as a scope when available. Fixes #35. Apr 18, 2018
package.json 2.0.10 Apr 18, 2018

README.md

Overview

Adds support for the timers module to browserify.

Wait, isn't it already supported in the browser?

The public methods of the timers module are:

  • setTimeout(callback, delay, [arg], [...])
  • clearTimeout(timeoutId)
  • setInterval(callback, delay, [arg], [...])
  • clearInterval(intervalId)

and indeed, browsers support these already.

So, why does this exist?

The timers module also includes some private methods used in other built-in Node.js modules:

  • enroll(item, delay)
  • unenroll(item)
  • active(item)

These are used to efficiently support a large quantity of timers with the same timeouts by creating only a few timers under the covers.

Node.js also offers the immediate APIs, which aren't yet available cross-browser, so we polyfill those:

  • setImmediate(callback, [arg], [...])
  • clearImmediate(immediateId)

I need lots of timers and want to use linked list timers as Node.js does.

Linked lists are efficient when you have thousands (millions?) of timers with the same delay. Take a look at timers-browserify-full in this case.

License

MIT