From 3c5a889a6ca5ee4010b6c2346f7ff9388bbbed54 Mon Sep 17 00:00:00 2001 From: Kevin Deng Date: Wed, 12 Nov 2025 05:47:42 +0800 Subject: [PATCH] fix: humanize unit --- playground/index.html | 2 +- playground/main.ts | 8 ++++---- src/utils.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/playground/index.html b/playground/index.html index 522e7e8..fce369c 100644 --- a/playground/index.html +++ b/playground/index.html @@ -3,7 +3,7 @@ - debug-es playground + obug playground diff --git a/playground/main.ts b/playground/main.ts index 8c6ad2f..aa8ef66 100644 --- a/playground/main.ts +++ b/playground/main.ts @@ -1,12 +1,12 @@ -import { Debug } from '../src/browser' +import { createDebug } from '../src/browser' -Debug.enable('test,test:subnamespace') -const debug = Debug('test') +createDebug.enable('test,test:subnamespace') +const debug = createDebug('test') debug('Hello World') debug('Hello %s', 'Kevin') debug('This is a number: %d', 42) -debug('This is a float: %f', 3.14159) +debug('This is a float: %f', Math.E) debug('This is an object: %O', { a: 1, b: 2 }) debug('This is a string: %s', 'sample string') debug('This is a JSON: %j', { key: 'value' }) diff --git a/src/utils.ts b/src/utils.ts index 176ae24..49293dd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -72,7 +72,7 @@ export function matchesTemplate(search: string, template: string): boolean { return templateIndex === template.length } -export function humanize(value: number): string | number { +export function humanize(value: number): string { if (value >= 1000) return `${(value / 1000).toFixed(1)}s` - return value + return `${value}ms` } -- 2.51.2