+2
-1
@@ -82,3 +82,3 @@ import { a as namespaces, i as enabled, n as disable, o as humanize, r as enable$1, s as selectColor, t as createDebug$1 } from "./core.js"; | ||
| const { useColors } = this; | ||
| args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${humanize(diff)}`; | ||
| args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`; | ||
| if (!useColors) return; | ||
@@ -109,2 +109,3 @@ const c = `color: ${this.color}`; | ||
| inspectOpts: {}, | ||
| humanize, | ||
| log | ||
@@ -111,0 +112,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| function e(e){return e instanceof Error?e.stack||e.message:e}function t(e,t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e[Math.abs(n)%e.length]}function n(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function r(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}let i=``;function a(){return i}function o(t,n){let r,a,s,c,l=(...t)=>{if(!l.enabled)return;let i=Date.now(),a=i-(r||i);r=i,t[0]=e(t[0]),typeof t[0]!=`string`&&t.unshift(`%O`);let o=0;t[0]=t[0].replace(/%([a-z%])/gi,(e,r)=>{if(e===`%%`)return`%`;o++;let i=n.formatters[r];if(typeof i==`function`){let n=t[o];e=i.call(l,n),t.splice(o,1),o--}return e}),n.formatArgs.call(l,a,t),l.log(...t)};return l.extend=function(e,t=`:`){return o(this.namespace+t+e,{useColors:this.useColors,color:this.color,formatArgs:this.formatArgs,formatters:this.formatters,inspectOpts:this.inspectOpts,log:this.log})},Object.assign(l,n),l.namespace=t,Object.defineProperty(l,`enabled`,{enumerable:!0,configurable:!1,get:()=>a==null?(s!==i&&(s=i,c=d(t)),c):a,set:e=>{a=e}}),l}let s=[],c=[];function l(e){i=e,s=[],c=[];let t=i.trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?c.push(e.slice(1)):s.push(e)}function u(){let e=[...s,...c.map(e=>`-${e}`)].join(`,`);return l(``),e}function d(e){for(let t of c)if(n(e,t))return!1;for(let t of s)if(n(e,t))return!0;return!1}const f=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function p(e,t){let{useColors:n}=this;if(t[0]=`${(n?`%c`:``)+this.namespace+(n?` %c`:` `)+t[0]+(n?`%c `:` `)}+${r(e)}`,!n)return;let i=`color: ${this.color}`;t.splice(1,0,i,`color: inherit`);let a=0,o=0;t[0].replace(/%[a-z%]/gi,e=>{e!==`%%`&&(a++,e===`%c`&&(o=a))}),t.splice(o,0,i)}const m=console.debug||console.log||(()=>{}),h=v(),g={useColors:!0,formatArgs:p,formatters:{j(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: ${e.message}`}}},inspectOpts:{},log:m};function _(e,n){var r;let i=(r=n&&n.color)==null?t(f,e):r;return o(e,Object.assign(g,{color:i},n))}function v(){try{return localStorage}catch(e){}}function y(){let e;try{e=h.getItem(`debug`)||h.getItem(`DEBUG`)}catch(e){}return!e&&typeof process<`u`&&`env`in process&&(e=process.env.DEBUG),e||``}function b(e){try{e?h.setItem(`debug`,e):h.removeItem(`debug`)}catch(e){}}function x(e){b(e),l(e)}l(y());export{_ as createDebug,u as disable,x as enable,d as enabled,a as namespaces}; | ||
| function e(e){return e instanceof Error?e.stack||e.message:e}function t(e,t){let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n|=0;return e[Math.abs(n)%e.length]}function n(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function r(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}let i=``;function a(){return i}function o(t,n){let r,a,s,c,l=(...t)=>{if(!l.enabled)return;let i=Date.now(),a=i-(r||i);r=i,t[0]=e(t[0]),typeof t[0]!=`string`&&t.unshift(`%O`);let o=0;t[0]=t[0].replace(/%([a-z%])/gi,(e,r)=>{if(e===`%%`)return`%`;o++;let i=n.formatters[r];if(typeof i==`function`){let n=t[o];e=i.call(l,n),t.splice(o,1),o--}return e}),n.formatArgs.call(l,a,t),l.log(...t)};return l.extend=function(e,t=`:`){return o(this.namespace+t+e,{useColors:this.useColors,color:this.color,formatArgs:this.formatArgs,formatters:this.formatters,inspectOpts:this.inspectOpts,log:this.log,humanize:this.humanize})},Object.assign(l,n),l.namespace=t,Object.defineProperty(l,`enabled`,{enumerable:!0,configurable:!1,get:()=>a==null?(s!==i&&(s=i,c=d(t)),c):a,set:e=>{a=e}}),l}let s=[],c=[];function l(e){i=e,s=[],c=[];let t=i.trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?c.push(e.slice(1)):s.push(e)}function u(){let e=[...s,...c.map(e=>`-${e}`)].join(`,`);return l(``),e}function d(e){for(let t of c)if(n(e,t))return!1;for(let t of s)if(n(e,t))return!0;return!1}const f=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function p(e,t){let{useColors:n}=this;if(t[0]=`${(n?`%c`:``)+this.namespace+(n?` %c`:` `)+t[0]+(n?`%c `:` `)}+${this.humanize(e)}`,!n)return;let r=`color: ${this.color}`;t.splice(1,0,r,`color: inherit`);let i=0,a=0;t[0].replace(/%[a-z%]/gi,e=>{e!==`%%`&&(i++,e===`%c`&&(a=i))}),t.splice(a,0,r)}const m=console.debug||console.log||(()=>{}),h=v(),g={useColors:!0,formatArgs:p,formatters:{j(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: ${e.message}`}}},inspectOpts:{},humanize:r,log:m};function _(e,n){var r;let i=(r=n&&n.color)==null?t(f,e):r;return o(e,Object.assign(g,{color:i},n))}function v(){try{return localStorage}catch(e){}}function y(){let e;try{e=h.getItem(`debug`)||h.getItem(`DEBUG`)}catch(e){}return!e&&typeof process<`u`&&`env`in process&&(e=process.env.DEBUG),e||``}function b(e){try{e?h.setItem(`debug`,e):h.removeItem(`debug`)}catch(e){}}function x(e){b(e),l(e)}l(y());export{_ as createDebug,u as disable,x as enable,d as enabled,a as namespaces}; |
+2
-0
@@ -28,2 +28,4 @@ import { InspectOptions } from "node:util"; | ||
| inspectOpts?: InspectOptions$1; | ||
| /** Humanize a duration in milliseconds */ | ||
| humanize?: (value: number) => string; | ||
| log?: (this: Debugger, ...args: any[]) => void; | ||
@@ -30,0 +32,0 @@ } |
+2
-1
@@ -77,3 +77,4 @@ function coerce(value) { | ||
| inspectOpts: this.inspectOpts, | ||
| log: this.log | ||
| log: this.log, | ||
| humanize: this.humanize | ||
| }); | ||
@@ -80,0 +81,0 @@ }; |
+3
-10
| import { a as namespaces, i as enabled, n as disable, o as humanize, r as enable$1, s as selectColor, t as createDebug$1 } from "./core.js"; | ||
| import { createRequire } from "node:module"; | ||
| import { isatty } from "node:tty"; | ||
| import { formatWithOptions, inspect } from "node:util"; | ||
| const require = createRequire(import.meta.url); | ||
| const colors = process.stderr.getColorDepth && process.stderr.getColorDepth() > 2 ? [ | ||
@@ -104,8 +102,2 @@ 20, | ||
| } | ||
| let humanize$1; | ||
| try { | ||
| humanize$1 = require("ms"); | ||
| } catch (_unused) { | ||
| humanize$1 = humanize; | ||
| } | ||
| function getDate() { | ||
@@ -122,3 +114,3 @@ if (inspectOpts.hideDate) return ""; | ||
| args[0] = prefix + args[0].split("\n").join(`\n${prefix}`); | ||
| args.push(`${colorCode}m+${humanize$1(diff)}\u001B[0m`); | ||
| args.push(`${colorCode}m+${this.humanize(diff)}\u001B[0m`); | ||
| } else args[0] = `${getDate()}${name} ${args[0]}`; | ||
@@ -143,3 +135,4 @@ } | ||
| inspectOpts, | ||
| log | ||
| log, | ||
| humanize | ||
| }; | ||
@@ -146,0 +139,0 @@ function createDebug(namespace, options) { |
+8
-16
| { | ||
| "name": "obug", | ||
| "version": "2.0.0", | ||
| "version": "2.1.0", | ||
| "description": "A lightweight JavaScript debugging utility, forked from debug, featuring TypeScript and ESM support.", | ||
@@ -38,17 +38,9 @@ "type": "module", | ||
| }, | ||
| "peerDependencies": { | ||
| "ms": "^2.0.0" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "ms": { | ||
| "optional": true | ||
| } | ||
| }, | ||
| "devDependencies": { | ||
| "@sxzz/eslint-config": "^7.2.10", | ||
| "@sxzz/prettier-config": "^2.2.4", | ||
| "@sxzz/eslint-config": "^7.3.0", | ||
| "@sxzz/prettier-config": "^2.2.5", | ||
| "@types/debug": "^4.1.12", | ||
| "@types/node": "^24.10.0", | ||
| "@vitest/browser-playwright": "^4.0.8", | ||
| "@vitest/coverage-v8": "^4.0.8", | ||
| "@types/node": "^24.10.1", | ||
| "@vitest/browser-playwright": "^4.0.10", | ||
| "@vitest/coverage-v8": "^4.0.10", | ||
| "bumpp": "^10.3.1", | ||
@@ -59,6 +51,6 @@ "debug": "^4.4.3", | ||
| "prettier": "^3.6.2", | ||
| "tsdown": "^0.16.2", | ||
| "tsdown": "^0.16.5", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.2.2", | ||
| "vitest": "^4.0.8" | ||
| "vitest": "^4.0.10" | ||
| }, | ||
@@ -65,0 +57,0 @@ "prettier": "@sxzz/prettier-config", |
+2
-1
@@ -24,3 +24,4 @@ # obug | ||
| - ES2015+ browsers | ||
| - Node.js 20.19 and above | ||
| - Modern Node.js versions | ||
| - 🎨 Customizable formatting | ||
@@ -27,0 +28,0 @@ ## Installation |
0
-100%109
0.93%21111
-0.42%473
-0.63%