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

approx

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

approx

Give me an approximate number around this one (for setTimeout/setInterval etc).

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

approx

Synopsis

If you'd like to do something every 10 seconds, you'd do something like this (or rather, use setInterval instead):

function something() {
  // ...
  setTimeout(something, 10 * 1000)
}

// kick it off
something()

But if you'd like to do something approximately every 10s:

var approx = require('approx')

function something() {
    // ...
    setTimeout(something, approx(10 * 1000))
}

// kick it off
something()

This will run something() approximately every 10 seconds. ie. it will run somewhere between 5 and 15 seconds, determined by Math.random().

Currently there is only one algorithm included in this package but could be expanded to provide more in the future.

Author

Written by Andrew Chilton:

License

MIT - http://chilts.mit-license.org/2015/

(Ends)

Keywords

FAQs

Package last updated on 19 Mar 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