{"library":"obug","title":"obug Lightweight Debugging Utility","description":"obug is a lightweight JavaScript debugging utility, forked from the popular `debug` package, specifically engineered for modern JavaScript environments. It offers comprehensive TypeScript support and native ES Module (ESM) compatibility, making it suitable for contemporary Node.js applications and browser environments (ES2015+). The current stable version is 2.1.1, with recent updates focusing on performance enhancements and customizable features. Unlike its predecessor `debug`, obug prioritizes a minimal footprint (7.7 kB package size, 1.4 KB minified + gzipped for browsers) and zero external dependencies. Key differentiators include full TypeScript type definitions, native ESM support from the ground up, and an API optimized for modern runtimes. Version 2 introduced a significant rewrite, refactoring API imports and usage for improved modularity, customization, and further reduced package size compared to v1, which aimed for `debug` compatibility but dropped older runtime support.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install obug"],"cli":null},"imports":["import { createDebug } from 'obug'","import { disable } from 'obug'","import { namespaces } from 'obug'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createDebug, disable, enable, enabled, namespaces } from 'obug';\n\n// Enable debug messages for 'my-namespace' and its sub-namespaces\nenable('my-namespace*');\n\n// Get the currently enabled namespaces\nconsole.log('Enabled namespaces:', namespaces());\n\nconst debug = createDebug('my-namespace', {\n  // All options are optional\n  useColors: true, // false, true, undefined for auto-detect\n  color: 2, // custom color (e.g., ANSI color code)\n  // custom formatArgs (Node.js only)\n  formatArgs(args) {\n    // Example: prepend a timestamp\n    args[0] = `[${new Date().toISOString()}] ${args[0]}`;\n  },\n  formatters: {}, // custom formatters (like debug.formatters)\n  // Node.js only options\n  inspectOpts: { depth: 4 },\n  // custom log function\n  log: console.log,\n});\n\n// This message will be logged because 'my-namespace' is enabled\ndebug('This is a debug message for %s', 'my-component');\nconsole.log(\n  'Namespace:', debug.namespace, // 'my-namespace'\n  'Enabled:', debug.enabled,     // true\n  'Using colors:', debug.useColors, // true\n);\n\n// Create a sub-namespace, inheriting options from the parent\nconst sub = debug.extend('sub-namespace');\nsub('This is a sub-namespace debug message with an object: %o', { id: 123, status: 'active' });\nconsole.log('Sub-namespace:', sub.namespace); // 'my-namespace:sub-namespace'\n\n// Example of disabling debug messages\ndisable('my-namespace*');\nconsole.log('Enabled after disable:', enabled('my-namespace')); // Should be false or empty\n\nconst debug2 = createDebug('another-namespace');\ndebug2('This message will NOT appear because its namespace is not enabled.');","lang":"typescript","description":"Demonstrates `obug` installation, creating debuggers, enabling/disabling namespaces, and using sub-namespaces.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}