{"name":"debug-fabulous","version":"2.0.104","keywords":["debug","lazy","lazy-eval"],"author":{"name":"Nicholas McCready"},"license":"MIT","_id":"debug-fabulous@2.0.104","maintainers":[{"name":"nmccready","email":"nemtcan@gmail.com"}],"contributors":[{"url":"https://github.com/zacronos","name":"Joe Ibershoff"}],"homepage":"https://github.com/brickhouse-tech/debug-fabulous#readme","bugs":{"url":"https://github.com/brickhouse-tech/debug-fabulous/issues"},"dist":{"shasum":"7219bedbd8a39b9b3866cb6820f610483ea049e2","tarball":"http://registry-npm.ywwl.com/debug-fabulous/download/debug-fabulous-2.0.104.tgz","fileCount":13,"integrity":"sha512-hJIJbfmaJz8eoaBGC3Gc487jhDk9qTYJRQcEQ8fzhdEopp8GBMGU0TWhETgbDMDYLMUWDxUK8rjBibSZ8ArO9g==","signatures":[{"sig":"MEYCIQDEm1ysXvXq4wSsZLgtysm4pUFbVroaFvo6PEIvhPQ+uQIhAIYXNhKJ0rADQJPz52/zBpS9u2BBR4SDMSpYrdWagz2I","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIBYGWu4NqEL0aZ8CoQt63pIkxb8qPGjak0ei6AQYHyrgAiBhkhBJXVECKE9Z0xhu76FM+j5UgtsA6Kjs/U7QN9SWVg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/debug-fabulous@2.0.104","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12316,"size":4845,"noattachment":false,"key":"/debug-fabulous/-/debug-fabulous-2.0.104.tgz"},"main":"lib/index.js","types":"./lib/index.d.ts","engines":{"node":">= 20"},"gitHead":"ad1cc272bc3c36501d8718fd93aacf3e2123ede1","scripts":{"lint":"npm run build && eslint *.js src test --color","test":"npm run build && vitest run","bench":"npm run build && vitest bench","build":"rm -rf lib && npx tsc","prepack":"npm run build","prepare":"npx sort-package-json","test:ci":"npm run build && vitest run --coverage","preversion":"npm run build","docs:api:website":"npx typedoc --exclude ./src/test --out docs ./src","docs:api:markdown":"npx typedoc --theme markdown --exclude ./src/test --out ./docs/api ./src"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:06e88fca-7fcf-4bcf-ba86-982a33bbcade"}},"repository":{"url":"git+https://github.com/brickhouse-tech/debug-fabulous.git","type":"git"},"_npmVersion":"11.19.0","description":"visionmedia debug extensions rolled into one","directories":{},"_nodeVersion":"24.20.0","dependencies":{"debug":"4.4.3"},"_hasShrinkwrap":false,"devDependencies":{"config":"^5.0.0","eslint":"10","vitest":"^4.0.18","globals":"^17.3.0","hook-std":"4.0","prettier":"^3.6.2","@eslint/js":"^10.0.1","JSONStream":"1.X","commitlint":"21","typescript":"^6.0.3","@types/node":"^26.0.0","@types/debug":"^4","@commitlint/cli":"^21","sort-package-json":"^3.0.0","@vitest/eslint-plugin":"^1.6.9","@typescript-eslint/parser":"^8.55.1-alpha.4","@commitlint/config-conventional":"^21","@typescript-eslint/eslint-plugin":"^8.55.1-alpha.4"},"_npmOperationalInternal":{"tmp":"tmp/debug-fabulous_2.0.104_1788953632396_0.47519681278002346","host":"s3://npm-registry-packages-npm-production"},"readme":"# debug-fabulous\n\n**Lazy-evaluation wrapper for [`debug`](https://github.com/debug-js/debug) — skip string building entirely when logging is disabled.**\n\n[![npm version](https://img.shields.io/npm/v/debug-fabulous.svg)](https://www.npmjs.com/package/debug-fabulous)\n[![npm downloads](https://img.shields.io/npm/dw/debug-fabulous.svg)](https://www.npmjs.com/package/debug-fabulous)\n[![tests](https://github.com/brickhouse-tech/debug-fabulous/actions/workflows/tests.yml/badge.svg)](https://github.com/brickhouse-tech/debug-fabulous/actions/workflows/tests.yml)\n\n## Why?\n\nThe `debug` module always evaluates its arguments, even when the namespace is disabled. If you're building expensive strings — JSON serialization, large object inspection, string concatenation — you pay the cost even when nobody's reading the output.\n\n**debug-fabulous** wraps `debug` with lazy evaluation. Pass a function instead of a string, and it only runs when the namespace is actually enabled. When logging is off, the call is a no-op — no string allocation, no concatenation, no wasted cycles.\n\nThis matters at scale. Libraries like [`gulp-sourcemaps`](https://www.npmjs.com/package/gulp-sourcemaps) (700K+ weekly downloads) use debug-fabulous as a transitive dependency for exactly this reason.\n\n## Install\n\n```bash\nnpm install debug-fabulous\n```\n\n## Quick Start\n\n```js\nconst debugFab = require('debug-fabulous');\nconst debug = debugFab()('my-app');\n\n// Lazy evaluation — the function only runs if 'my-app' is enabled\ndebug(() => 'user object: ' + JSON.stringify(largeUserObject));\n\n// Plain strings still work\ndebug('server started on port %d', 3000);\n```\n\n### Spawning Child Debuggers\n\nCreate hierarchical namespaces without string juggling:\n\n```js\nconst debugFab = require('debug-fabulous');\nconst debug = debugFab()('my-app');\n\nconst dbDebug = debug.spawn('db');       // my-app:db\nconst queryDebug = dbDebug.spawn('query'); // my-app:db:query\n\ndbDebug('connected');\nqueryDebug(() => `SELECT took ${ms}ms, returned ${rows.length} rows`);\n```\n\n### Standalone Spawnable\n\nIf you just need hierarchical debuggers without the factory:\n\n```js\nconst { spawnable } = require('debug-fabulous');\nconst debug = spawnable('my-app');\n\nconst child = debug.spawn('worker');  // my-app:worker\nchild('processing job %d', jobId);\n```\n\n## TypeScript\n\ndebug-fabulous is written in TypeScript and ships type declarations.\n\n```ts\nimport debugFab, { spawnable } from 'debug-fabulous';\n\nconst debug = debugFab()('my-app');\n\n// Lazy eval with type safety\ndebug(() => `processed ${items.length} items`);\n\n// Spawn children\nconst child = debug.spawn('worker');\nchild('ready');\n\n// Return an array for format strings\ndebug(() => ['found %d results in %dms', count, elapsed]);\n```\n\n## API\n\n### `debugFab(debugApi?)`\n\nReturns a wrapped `debug` factory with lazy evaluation and namespace caching.\n\n- **`debugApi`** *(optional)* — a custom `debug` instance. Defaults to `require('debug')`.\n\nThe returned factory has the same API as `debug` (`enable()`, `disable()`, `load()`, `save()`, etc.) plus lazy evaluation support.\n\n### `debug(fn)` — Lazy Evaluation\n\nPass a function instead of a string. It's only called when the namespace is enabled:\n\n```js\n// Function returns a string\ndebug(() => expensiveStringOperation());\n\n// Function returns [formatter, ...args] array\ndebug(() => ['user %s performed %d actions', userName, count]);\n```\n\n### `debug.spawn(namespace)`\n\nCreates a child debugger under the current namespace:\n\n```js\nconst root = debug('app');       // app\nconst db = root.spawn('db');     // app:db\nconst cache = db.spawn('cache'); // app:db:cache\n```\n\n### `spawnable(namespace, debugFabFactory?)`\n\nStandalone function that creates a spawnable debugger directly:\n\n```js\nconst { spawnable } = require('debug-fabulous');\nconst debug = spawnable('app');\n```\n\n## How It Works\n\n1. **Namespace caching** — `Map`-based memoization means repeated `debug('same-ns')` calls return the same instance instantly.\n2. **Singleton no-op** — Disabled namespaces get a shared no-op function instead of allocating per-instance.\n3. **Lazy closures** — When you pass a function, it's never invoked if the namespace is disabled. No string allocation, no concatenation, no `JSON.stringify()`.\n\n## Sponsor\n\nIf you find this project useful, consider [sponsoring @nmccready](https://github.com/sponsors/nmccready) to support ongoing maintenance and development. ❤️\n\n## License\n\n[MIT](./LICENSE) — Nicholas McCready and [contributors](https://github.com/brickhouse-tech/debug-fabulous/graphs/contributors).\n","publish_time":1788953632499,"_cnpm_publish_time":1788953632499,"dist-tags":{"latest":"2.0.130"}}