Coder Social home page Coder Social logo

timers-browserify's Introduction

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

timers-browserify's People

Contributors

jryans avatar jscissr avatar jhnns avatar guybedford avatar icflorescu avatar matt-esch avatar

Watchers

Long Ho avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.