Neural Processing Mechanisms
    Wondering what’s next for npm?Check out our public roadmap! »

    approx

    1.0.0 • Public • Published

    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)

    Install

    npm i approx

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar