You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

4 years ago
  1. # Overview
  2. Adds support for the `timers` module to browserify.
  3. ## Wait, isn't it already supported in the browser?
  4. The public methods of the `timers` module are:
  5. * `setTimeout(callback, delay, [arg], [...])`
  6. * `clearTimeout(timeoutId)`
  7. * `setInterval(callback, delay, [arg], [...])`
  8. * `clearInterval(intervalId)`
  9. and indeed, browsers support these already.
  10. ## So, why does this exist?
  11. The `timers` module also includes some private methods used in other built-in
  12. Node.js modules:
  13. * `enroll(item, delay)`
  14. * `unenroll(item)`
  15. * `active(item)`
  16. These are used to efficiently support a large quantity of timers with the same
  17. timeouts by creating only a few timers under the covers.
  18. Node.js also offers the `immediate` APIs, which aren't yet available cross-browser, so we polyfill those:
  19. * `setImmediate(callback, [arg], [...])`
  20. * `clearImmediate(immediateId)`
  21. ## I need lots of timers and want to use linked list timers as Node.js does.
  22. Linked lists are efficient when you have thousands (millions?) of timers with the same delay.
  23. Take a look at [timers-browserify-full](https://www.npmjs.com/package/timers-browserify-full) in this case.
  24. # License
  25. [MIT](http://jryans.mit-license.org/)