{"name":"obug","version":"2.1.3","author":"Kevin Deng <sxzz@sxzz.moe>","license":"MIT","_id":"obug@2.1.3","maintainers":[{"name":"sxzz","email":"npm@sxzz.moe"}],"homepage":"https://github.com/sxzz/obug#readme","bugs":{"url":"https://github.com/sxzz/obug/issues"},"dist":{"shasum":"c02c60f95abd603409330e767db7f2823193331e","tarball":"http://registry-npm.ywwl.com/obug/download/obug-2.1.3.tgz","fileCount":10,"integrity":"sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==","signatures":[{"sig":"MEUCIQCbpsR1GGc33Pobo35Dccm7lo0UrqFQMBqv41YF/zThqAIgc6c6hOVdPBGf+GqPL4jNzCb8qTbuUbKbVY7XGa1bmRg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/obug@2.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":27144,"size":10210,"noattachment":false,"key":"/obug/-/obug-2.1.3.tgz"},"main":"./dist/node.js","type":"module","types":"./dist/browser.d.ts","unpkg":"./dist/browser.min.js","module":"./dist/node.js","engines":{"node":">=12.20.0"},"exports":{".":{"browser":"./dist/browser.js","default":"./dist/node.js"},"./package.json":"./package.json"},"funding":["https://github.com/sponsors/sxzz","https://opencollective.com/debug"],"scripts":{"dev":"tsdown --watch","lint":"eslint --cache .","play":"vite playground","test":"vitest","build":"tsdown","format":"prettier --cache --write .","release":"bumpp","lint:fix":"pnpm run lint --fix","typecheck":"tsgo --noEmit","test:coverage":"vitest --project node --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","approver":{"name":"sxzz","email":"npm@sxzz.moe"},"trustedPublisher":{"id":"github","oidcConfigId":"oidc:5b5ac195-23c7-4d6a-830a-047e5f7266aa"}},"jsdelivr":"./dist/browser.min.js","prettier":"@sxzz/prettier-config","repository":{"url":"git+https://github.com/sxzz/obug.git","type":"git"},"description":"A lightweight JavaScript debugging utility, forked from debug, featuring TypeScript and ESM support.","directories":{},"sideEffects":false,"_nodeVersion":"24.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.16","bumpp":"^11.1.0","debug":"^4.4.3","eslint":"^10.4.1","tsdown":"^0.22.2","vitest":"^4.1.8","prettier":"^3.8.4","playwright":"^1.60.0","typescript":"^6.0.3","@types/node":"^25.9.2","@types/debug":"^4.1.13","@sxzz/eslint-config":"^8.1.0","@vitest/coverage-v8":"^4.1.8","@sxzz/prettier-config":"^2.3.1","@typescript/native-preview":"7.0.0-dev.20260609.1","@vitest/browser-playwright":"^4.1.8"},"_npmOperationalInternal":{"tmp":"tmp/obug_2.1.3_1781271924552_0.4990880200603591","host":"s3://npm-registry-packages-npm-production"},"readme":"# obug\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![JSR][jsr-badge-src]][jsr-badge-href]\n[![Unit Test][unit-test-src]][unit-test-href]\n\nA lightweight JavaScript debugging utility, forked from [debug](https://www.npmjs.com/package/debug), featuring TypeScript and ESM support.\n\n> [!NOTE]\n> obug v1 retains most of the compatibility with [debug](https://github.com/debug-js/debug), but drops support for older browsers and Node.js, making it a drop-in replacement.\n>\n> obug v2 refactors some API imports and usage for better support of ESM and TypeScript, easier customization, and an even smaller package size.\n\n## Key Differences from `debug`\n\n- ✨ Minimal footprint\n  - 7.7 kB package size\n  - 1.4 KB minified + gzipped for browsers\n- 📦 Zero dependencies\n- 📝 Full TypeScript support\n- 🚀 Native ESM compatibility\n- 🌐 Optimized for modern runtimes\n  - ES2015+ browsers\n  - Modern Node.js versions\n- 🎨 Customizable formatting\n\n## Installation\n\n```bash\nnpm install obug\n```\n\n## Usage\n\n```ts\nimport { createDebug, disable, enable, enabled, namespaces } from 'obug'\n\n// Get the currently enabled namespaces\nconsole.log(namespaces())\n\nconst debug = createDebug('my-namespace', {\n  // All options are optional\n\n  useColors: true, // false, true, undefined for auto-detect\n  color: 2, // custom color\n  // custom formatArgs\n  formatArgs(args) {},\n  formatters: {},\n  // Node.js only\n  inspectOpts: {},\n\n  // custom log\n  log: console.log,\n})\n\ndebug('This is a debug message')\nconsole.log(\n  debug.namespace, // 'my-namespace'\n  debug.enabled, // Check if enabled\n  debug.useColors, // true\n  debug.color, // 2\n  debug.formatArgs, // custom formatArgs\n  debug.formatters, // {}\n  debug.inspectOpts, // {}\n  debug.log, // implemented log function\n)\n\n// Create a sub-namespace, and it will inherit options from the parent debugger\nconst sub = debug.extend('sub-namespace')\nsub('This is a sub-namespace debug message')\nconsole.log(sub.namespace) // 'my-namespace:sub-namespace'\n```\n\n## How to use\n\n### Enabling debug output\n\nobug picks up enabled namespaces from the `DEBUG` environment variable in Node.js, or from `localStorage.debug` in browsers.\n\nIn Node.js:\n\n```bash\nDEBUG=app:* node app.js\n```\n\nOn Windows (CMD):\n\n```cmd\nset DEBUG=app:* & node app.js\n```\n\nOn Windows (PowerShell):\n\n```powershell\n$env:DEBUG='app:*'; node app.js\n```\n\nIn the browser, set the value in DevTools and refresh the page:\n\n```js\nlocalStorage.debug = 'app:*'\n```\n\n### Wildcards and exclusion\n\nThe `*` character is a wildcard. Suppose your library has debuggers named `connect:bodyParser`, `connect:compress`, and `connect:session` — instead of listing each one, use `DEBUG=connect:*`. Use `DEBUG=*` to enable everything.\n\nExclude namespaces by prefixing them with `-`:\n\n```bash\nDEBUG=*,-connect:* node app.js\n```\n\n### Namespace conventions\n\nIf you're using obug in a library, prefix your namespaces with the library name and use `:` to separate features (e.g. `connect:bodyParser`). This lets users opt into the parts they care about without guessing names.\n\n### Extending a namespace\n\nUse `.extend()` to create a sub-namespace that inherits options from its parent:\n\n```ts\nconst log = createDebug('auth')\nconst logSign = log.extend('sign') // 'auth:sign'\nconst logLogin = log.extend('login') // 'auth:login'\n\nlog('hello') // auth hello\nlogSign('hello') // auth:sign hello\nlogLogin('hello') // auth:login hello\n```\n\n### Formatters\n\nobug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Built-in formatters:\n\n| Formatter | Representation                                     |\n| --------- | -------------------------------------------------- |\n| `%O`      | Pretty-print an Object on multiple lines.          |\n| `%o`      | Pretty-print an Object all on a single line.       |\n| `%%`      | Single percent sign. Does not consume an argument. |\n\nOther format specifiers supported by Node's `util.format` (`%s`, `%d`, `%j`, …) and the browser console pass through to the underlying logger.\n\n#### Custom formatters\n\nRegister custom formatters via the `formatters` option. For example, to render a `Buffer` as hex with `%h`:\n\n```ts\nconst debug = createDebug('foo', {\n  formatters: {\n    h: (v) => v.toString('hex'),\n  },\n})\n\ndebug('this is hex: %h', Buffer.from('hello world'))\n//   foo this is hex: 68656c6c6f20776f726c64 +0ms\n```\n\n### Dynamic enable / disable\n\nYou can toggle namespaces at runtime:\n\n```ts\nimport { disable, enable, enabled, namespaces } from 'obug'\n\nenable('app:*')\nconsole.log(enabled('app:server')) // true\n\nconst previous = disable()\nconsole.log(enabled('app:server')) // false\n\n// Restore later\nenable(previous)\n```\n\n`namespaces()` returns the string of currently enabled namespaces. Note that calling `enable()` overrides the value initially read from `DEBUG`.\n\n### Checking whether a debugger is enabled\n\nGuard expensive work behind the `enabled` property:\n\n```ts\nconst debug = createDebug('http')\n\nif (debug.enabled) {\n  // expensive computation only when enabled\n}\n```\n\nYou can also force the state by assigning to `debug.enabled` directly.\n\n### Custom output\n\nBy default, obug writes to `stderr` in Node.js and to the console in browsers. Override the `log` option to redirect output per-namespace:\n\n```ts\nconst log = createDebug('app:log', {\n  log: console.log,\n})\n\nconst error = createDebug('app:error') // still goes to stderr\n```\n\n### Environment variables (Node.js)\n\n| Name                | Purpose                                         |\n| ------------------- | ----------------------------------------------- |\n| `DEBUG`             | Enables/disables specific debugging namespaces. |\n| `DEBUG_HIDE_DATE`   | Hide date from debug output (non-TTY).          |\n| `DEBUG_COLORS`      | Whether to use colors in the debug output.      |\n| `DEBUG_DEPTH`       | Object inspection depth.                        |\n| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects.   |\n\nVariables prefixed with `DEBUG_` are converted to camelCase keys on the options object passed to Node's [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) for the `%o` / `%O` formatters.\n\n## Original Authors\n\nAs obug is a fork of debug with significant modifications, we would like to acknowledge the original authors:\n\n- TJ Holowaychuk\n- Nathan Rajlich\n- Andrew Rhyne\n- Josh Junon\n\n## Sponsors\n\n<p align=\"center\">\n  <a href=\"https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg\">\n    <img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>\n  </a>\n</p>\n\n## License\n\n[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)\n\n[The MIT License](./LICENSE) Copyright (c) 2014-2017 TJ Holowaychuk &lt;tj@vision-media.ca&gt;\n\n[The MIT License](./LICENSE) Copyright (c) 2018-2021 Josh Junon\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/obug.svg\n[npm-version-href]: https://npmjs.com/package/obug\n[npm-downloads-src]: https://img.shields.io/npm/dm/obug\n[npm-downloads-href]: https://www.npmcharts.com/compare/obug?interval=30\n[unit-test-src]: https://github.com/sxzz/obug/actions/workflows/unit-test.yml/badge.svg\n[unit-test-href]: https://github.com/sxzz/obug/actions/workflows/unit-test.yml\n[jsr-badge-src]: https://jsr.io/badges/@sxzz/obug\n[jsr-badge-href]: https://jsr.io/@sxzz/obug\n","publish_time":1781271924644,"_cnpm_publish_time":1781271924644,"dist-tags":{"latest":"3.0.0","latest-v1":"1.0.2"}}