1- import { createRequire } from 'node:module'
21import { isatty } from 'node:tty'
32import { formatWithOptions , inspect } from 'node:util'
43import {
@@ -8,11 +7,9 @@ import {
87 enabled ,
98 namespaces ,
109} from './core.ts'
11- import { humanize as _humanize , selectColor } from './utils.ts'
10+ import { humanize , selectColor } from './utils.ts'
1211import type { Debugger , DebugOptions , InspectOptions } from './types.ts'
1312
14- const require = createRequire ( import . meta. url )
15-
1613const colors : number [ ] =
1714 process . stderr . getColorDepth && process . stderr . getColorDepth ( ) > 2
1815 ? [
@@ -63,13 +60,6 @@ function useColors(): boolean {
6360 : isatty ( process . stderr . fd )
6461}
6562
66- let humanize : typeof _humanize
67- try {
68- humanize = require ( 'ms' )
69- } catch {
70- humanize = _humanize
71- }
72-
7363function getDate ( ) : string {
7464 if ( inspectOpts . hideDate ) {
7565 return ''
@@ -93,7 +83,7 @@ function formatArgs(
9383 const prefix = ` ${ colorCode } ;1m${ name } \u001B[0m`
9484
9585 args [ 0 ] = prefix + args [ 0 ] . split ( '\n' ) . join ( `\n${ prefix } ` )
96- args . push ( `${ colorCode } m+${ humanize ( diff ) } \u001B[0m` )
86+ args . push ( `${ colorCode } m+${ this . humanize ( diff ) } \u001B[0m` )
9787 } else {
9888 args [ 0 ] = `${ getDate ( ) } ${ name } ${ args [ 0 ] } `
9989 }
@@ -130,6 +120,7 @@ const defaultOptions: Omit<Required<DebugOptions>, 'color'> = {
130120 inspectOpts,
131121
132122 log,
123+ humanize,
133124}
134125
135126export function createDebug (
0 commit comments