warn-once
Print a console warning exactly once during development
Repository Health
Technical Analysis
warn-once is a tiny, zero-dependency JavaScript utility that prints a warning message to the console exactly once, no matter how many times it is called with the same message. It is designed for development-time notices such as deprecation warnings or reminders about missing setup, so noisy logs stay readable.
The warnOnce function takes a condition followed by one or more message arguments; it only emits when the condition is truthy and only in non-production environments (when NODE_ENV is not set to production), making it safe to leave in library and application code without cluttering production output.
What You Get
- A single warnOnce(condition, …messages) function
- Automatic de-duplication so each unique message prints only once
- Development-only behavior gated on NODE_ENV not being production
- Support for multiple message arguments passed straight to console.warn
- TypeScript type definitions and zero runtime dependencies
Common Use Cases
- Emitting deprecation warnings from a library without spamming the console
- Reminding developers about missing or incorrect setup once per session
- Guarding warnings behind a runtime condition
- Keeping development logs clean while still surfacing important notices
Under The Hood
Architecture - The entire implementation is a single function in index.js. It holds a module-level Set of already-printed message keys, computes a key by joining the message arguments, and calls console.warn only when the DEV flag is set, the condition is truthy, and the key has not been seen before.
Tech Stack - Plain CommonJS JavaScript with no dependencies, shipping an index.d.ts for TypeScript consumers. The development check reads process.env.NODE_ENV once at module load.
Code Quality - The code is minimal and easy to audit - a dozen lines with a clear guard clause and a Set-based dedupe. There is no test suite in the repository, which is unsurprising given the trivial surface area, though it means correctness rests on the simplicity of the logic.
API Design - The API is about as small as it gets: one default-exported function whose signature (condition first, then variadic messages) mirrors a conditional console.warn. This makes it instantly familiar and trivial to drop into existing warning call sites.
Used by 2 apps in this directory
OpenPanel
Hosting Control Panel · Devops
Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.
Webstudio
Design Tools · No Code Platforms
Open source visual development platform with complete CSS control, headless CMS integration, and full infrastructure ownership