diff --git a/README.md b/README.md index d554c16..54c4c61 100644 --- a/README.md +++ b/README.md @@ -31,52 +31,6 @@ npm install obug Please refer to the original [debug](https://github.com/debug-js/debug#usage) package for usage instructions. -## Refactor Plan - -The obug package is currently a direct fork of the debug package with minimal modifications. The following refactor plan outlines the intended changes to be made in future releases. - -```ts -import { createDebug, disable, enable, enabled, namespaces } from 'obug' - -// Get the currently enabled namespaces -console.log(namespaces()) - -// createDebug has no extra properties or methods. -const debug = createDebug('my-namespace', { - // All options are optional - - useColors: true, // false, true, 'auto' - color: 2, // custom color - // custom formatArgs - formatArgs(args) {}, - formatters: {}, - // Node.js only - inspectOpts: {}, - - // custom log - log: console.log, -}) - -debug('This is a debug message') -console.log( - debug.namespace, // 'my-namespace' - debug.enabled, // Check if enabled - debug.useColors, // true - debug.color, // 2 - debug.formatArgs, // custom formatArgs - debug.formatters, // {} - debug.inspectOpts, // {} - debug.log, // implemented log function -) - -// Create a sub-namespace, and it will inherit options from the parent debugger -const sub = debug.extend('sub-namespace') -sub('This is a sub-namespace debug message') -console.log(sub.namespace) // 'my-namespace:sub-namespace' -``` - -For more details, please refer to the [src/types-v2.ts](./src/types-v2.ts). - ## Original Authors As obug is a fork of debug, we would like to acknowledge the original authors: diff --git a/src/types-v2.ts b/src/types-v2.ts deleted file mode 100644 index 24974bc..0000000 --- a/src/types-v2.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { InspectOptions as NodeInspectOptions } from 'node:util' - -/** - * Disable debug output. - */ -export declare function disable(): string -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - */ -export declare function enable(namespaces: string): void -/** - * Returns true if the given mode name is enabled, false otherwise. - */ -export declare function enabled(namespaces: string): boolean -/** - * Returns an array of the currently enabled debug namespaces. - */ -export declare function namespaces(): string[] - -export interface InspectOptions extends NodeInspectOptions { - hideDate?: boolean -} - -export interface Formatters { - [formatter: string]: (this: Debugger, v: any) => string -} - -export interface Debugger extends Required { - (formatter: any, ...args: any[]): void - - namespace: string - enabled: boolean - - extend: (namespace: string, delimiter?: string) => Debugger -} - -export interface DebugOptions { - useColors?: boolean - color?: string | number - - formatArgs?: (this: Debugger, diff: number, args: [string, ...any[]]) => void - formatters?: Formatters - /** Node.js only */ - inspectOpts?: InspectOptions - - log?: (this: Debugger, ...args: any[]) => void -}