{"library":"process-warning","title":"Process Warning Utility","description":"process-warning is a lightweight utility designed to standardize the creation and emission of warnings within JavaScript and TypeScript applications, particularly for the Fastify ecosystem. It ensures that warnings, including deprecation warnings, are consistently formatted and, by default, emitted only once to prevent log spam. The current stable version is 5.0.0. The package maintains a regular release cadence, often aligning with Node.js version updates and Fastify development, with minor releases for bug fixes and dependency bumps and occasional major releases for refactoring or dropping older Node.js support. Its key differentiators include built-in one-time emission, support for Node.js's native deprecation warning CLI options, and a clear API for defining warning codes and messages.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install process-warning"],"cli":null},"imports":["import { createWarning } from 'process-warning'","import { createDeprecation } from 'process-warning'","import type { WarningFunction } from 'process-warning'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createWarning, createDeprecation } from 'process-warning';\n\nconst MyModuleWarning = createWarning({\n  name: 'MyModuleWarning',\n  code: 'MYMOD_001',\n  message: 'This is a warning for value: %s'\n});\n\nconst MyModuleDeprecation = createDeprecation({\n  code: 'MYMOD_DEP_002',\n  message: 'The %s method is deprecated, use %s instead.'\n});\n\nconsole.log('Emitting first warning...');\nMyModuleWarning('someValue'); // Emits the warning\n\nconsole.log('Attempting to emit same warning again...');\nMyModuleWarning('anotherValue'); // Will not emit by default (unlimited: false)\n\nconsole.log('Emitting deprecation warning...');\nMyModuleDeprecation('oldMethod', 'newMethod'); // Emits a deprecation warning\n\nconst UnlimitedWarning = createWarning({\n  name: 'UnlimitedWarning',\n  code: 'UNL_003',\n  message: 'This warning will always emit for %s',\n  unlimited: true\n});\n\nconsole.log('Emitting unlimited warning...');\nUnlimitedWarning('first call'); // Emits\nUnlimitedWarning('second call'); // Emits again\n","lang":"typescript","description":"Demonstrates creating and emitting both standard and deprecation warnings, including the 'unlimited' option.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}