Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timers-ref

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timers-ref

`setTimeout` and `setInterval` with `unref` and `ref` like in node.js

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

timers-ref travis npm downloads

Sauce Test Status

setTimeout and setInterval with unref and ref like in node.js

Please only use this in the browser, not in node.

install

npm install timers-ref

usage

var timers = require('timers-ref')

timers.setTimeout(function () {
  console.log('hi')
}, 100)

timers.setInterval(function () {
  console.log('hi')
}, 100)

var timeout = timers.setTimeout(function () {}, 100)
timers.clearTimeout(timeout)

var interval = timers.setInterval(function () {}, 100)
timers.clearInterval(interval)

If you want to listen to process.on('exit') to know when there are no setTimeout or setInterval timers in the event queue, do this:

timers.setupProcess()

process.once('exit', function (code) {
  console.log('all done')
})

Note one important difference: This won't emit process.on('exit') if no setTimeouts or setIntervals are called. Needs at least one call to get things going.

license

MIT. Copyright (c) Feross Aboukhadijeh.

Keywords

FAQs

Package last updated on 05 May 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc