Socket
Socket
Sign inDemoInstall

timers-browserify

Package Overview
Dependencies
1
Maintainers
41
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    timers-browserify

timers module for browserify


Version published
Weekly downloads
7.3M
decreased by-14.15%
Maintainers
41
Install size
20.9 kB
Created
Weekly downloads
 

Package description

What is timers-browserify?

The timers-browserify npm package is a browser-compatible version of Node.js' timers module, providing timer functions such as setTimeout, setInterval, and others. It allows developers to use the same API in both Node.js and browser environments, facilitating code sharing and reuse.

What are timers-browserify's main functionalities?

setTimeout

Delays the execution of a function by a specified number of milliseconds.

setTimeout(function() { console.log('Timer triggered!'); }, 1000);

clearTimeout

Cancels a timeout previously established by calling setTimeout.

var timerId = setTimeout(function() { console.log('This will not be logged.'); }, 1000); clearTimeout(timerId);

setInterval

Repeatedly calls a function with a fixed time delay between each call.

setInterval(function() { console.log('Interval triggered!'); }, 2000);

clearInterval

Cancels a timed, repeating action which was previously established by a call to setInterval.

var intervalId = setInterval(function() { console.log('This will keep logging.'); }, 2000); clearInterval(intervalId);

Other packages similar to timers-browserify

Changelog

Source

2.0.12 - 2020-10-27

Fixed

  • Remove .DS_Store from published package
  • Upgrade connect dev dependency

Readme

Source

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

Keywords

FAQs

Last updated on 27 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc