包详细信息

@idio/debug

idiocc73MIT1.2.3

The Fork Of Debug For Node.JS Written In ES6 And Optimised With JavaScript Compiler.

debug, idio

自述文件

@idio/debug

npm version

@idio/debug is the fork of the popular debug package that was rewritten in modern JS using the ES6 modules, to be able to compile it with Closure Compiler. Currently, only the Node.JS version is supported.

yarn add @idio/debug

Table Of Contents

API

The package is available by importing its default function:

import debug from '@idio/debug'

debug(
  namespace: string,
): debugFunction

Creates a debug function for the given namespace.

import debug from '@idio/debug'

const log = debug('example')
log('hello')
log('world')
example hello +0ms
  example world +4ms
<summary>Show Types</summary> _debug.Env: An environment. | Name | Type | Description | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | init* | function(_debug.DebugFunction) | Env-specific initialization logic for debug instances. | | log* | function(...) | The logging function. | | __formatArgs | function(this: _debug.DebugFunction, !Array) | Apply env-specific formatting (colors, etc.). | | save | !Function | Save namespaces. | | load | !Function | Load namespaces. | | formatters | Object<string, function(!Object): string> | Map of special "%n" handling functions, for the debug "format" argument. Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". | | useColors | !Function | Is stdout a TTY? Colored output is enabled when true. | | colors | !Array<number> | The array of supported colors. | | inspectOpts | !Object<string, *> | The options from the env variables, e.g., DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js. | _debug.DebugContext | Name | Type | Description | | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | | namespace | string | The namespace for which the debug function was setup. | | enabled | boolean | Whether the debug function is enabled. | | useColors | boolean | If the environment uses colors. | | diff | number | The diff between the prev time and current time. | | prev | number | The previous time. | | curr | number | The current time. | | log | function(...*) | The manually set logging function that overrides the environment log function. | | color | (number | string) | The color for the namespace. | | destroy | function(this: _debug.DebugFunction): boolean | Removes the debug function from the namespace. | | extend__ | function(this: _debug.DebugFunction, string, string): _debug.DebugFunction | Using the debug function, creates a new one. | `function(this:_debug.DebugContext, ...)__<a name="type-_debugdebugfunction">_debug.DebugFunction`__: The setup debug function.

Modifiers

The modifiers can be used to print information in formatted way.

Modifier Action
%O Multiline inspect.
%o Single line inspect.
%f File-size format of bytes, e.g., 10MB.
%fy File-size in yellow.
%fr File-size in red.
%fb File-size in blue.
%fg File-size in green.
%fc File-size in cyan
%fm File-size in magenta.
import Debug from '@idio/debug'

const debug = Debug('example')
debug('hello %O', { test: 'ok' })
debug('world %f', 105248)
example hello { test: 'ok' } +0ms
  example world 102.78KB +16ms

Copyright

Original Authors:

  • TJ Holowaychuk
  • Nathan Rajlich
  • Andrew Rhyne

Art Deco © Art Deco for Idio 2019 Idio Tech Nation Visa Tech Nation Visa Sucks

更新日志

17 July 2019

1.2.3

1.2.2

  • [package] Publish missing 1.2.1 again.

1.2.1

  • [fix] Correct file size formatters (plain & with color).

1.2.0

  • [feature] File size formatters.

9 May 2019

1.1.1

  • [deps] Bundle up ms.

7 May 2019

1.1.0

  • [fix] Remove ms dependency.
  • [doc] Provide JSDoc for the exported package.

19 April 2019

1.0.0

  • [package] Publish version v1.0.0.

18 April 2019

0.0.0