npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@buzuli/throttle

v2.0.2

Published

Report function throttler for enforcing delays between reports.

Downloads

3,260

Readme

throttle

Build Status NPM version

Controls the frequency at which a report function is called.

Installation

npm install @buzuli/throttle

Usage

const throttle = require('@buzuli/throttle')

const notify = throttle(options)

API

The throttle package exports the function (aliased throttle). This function accepts an object (aliased options) and returns a notifier function (aliased notify).

options

  • reportFunc - the report function which will be run at the maxDelay interval
    • type is function
    • default is undefined
    • if undefined or null, it is a no-op not an error
    • may be replaced at any time using the notify function
  • minDelay - reports will never run more frequently than this
    • type is number
    • units is milliseconds
    • default is 1000
    • if undefined or null, the default value is used
  • maxDelay - reports will be forced at this frequency
    • type is number
    • units is milliseconds
    • default is 5000
    • if undefined, the default value is used
    • if null or <= 0, then reports will only run when triggered by a notifier event
    • if < minDelay, the value of minDelay will be used in its stead

notify({reportFunc, force, halt})

The notifier function causes the internal notification count to increase, and will cause the report function to be run if minDelay has been met.

If maxDelay is > 0, reports will be forced when it has been >= maxDelay milliseconds since the last report.

If maxDelay is null or <= 0 and the notify function has NOT been called, then reports will not be scheduled.

If maxDelay is null or <= 0 and the notify function HAS been called, then a report will either be run (if time since last reports > minDelay) or will be schedule to run in reportDelay = minDelay - (now - lastReport).

If reportFunc is a function, it will replace the report function for this and all further reports.

If force is true, the report will be run, even if the time elapsed since the last run is less than minDelay.

If halt is true, the next notification will not be scheduled, permitting the process to halt.