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

limit-logger

v1.0.2

Published

A tiny TypeScript library that lets you put limits on how frequently console.log is called. Useful for debugging animation loops.

Downloads

3

Readme

Limit Logger (limit-logger)

License NPM Version

Limit Logger is a small library that exposes common console logging functions with an added minimum frequency parameter. Subsequent calls that happen before the given frequency is elapsed are discarded. This allows you to avoid flooding the console with logging statements.

The main inspiration for writing this is while working with 2D/3D canvas rendering and animation loops (for ex. with Window.requestAnimationFrame()) and wanting to log debug output, but only needing it once every second and not once every frame.

Usage

Limit Logger exposes a single LimitLogger export, on which you can call the following logger functions.

Each call must be given a logId (a unique string used for tracking subsequent calls) and a minimumFrequencyInSeconds (the minimum number of seconds that must pass before outputting another message with the same logId, fractional values are supported).

Debug

// Log the debug message "I'm a debug message!" no more than once every 5 seconds.
LimitLogger.debug(`I'm a debug message!`, `Debug1`, 5);

Info

// Log the `SomeObject` object no more than once every 250 milliseconds.
LimitLogger.info(SomeObject, `Info`, .25);

Log

// Log the "Testing" log message no more than once every second.
LimitLogger.log(`Testing`, `Debug1`, 1);

Warn

// Log the "Warning" log message no more than once five seconds.
LimitLogger.warn(`Warning`, `Manager.js:52`, 5);

Error

// Log a blank error no more than once every minute.
LimitLogger.error(new Error(), `Error1`, 60);

Advanced Usages

// Log only one message with the `Log.ts` id every minute.
// The first subsequent call after 60 seconds will be outputted.
LimitLogger.log("An output message", `Log.ts`, 60);
...
LimitLogger.log("An different output message", `Log.ts`, 60);
// Log the first message only once every minute.
// However allow the second message to be written after only 15 seconds have elapsed.
LimitLogger.error("Something bad happened.", `Error`, 60);
...
LimitLogger.error("Something really bad happened!", `Error`, 15);