node:util
Node-compatible formatting, inspection, promisification, CLI argument parsing, VT/ANSI helpers, and UTF-8 text encoding utilities.
Available in both vjs and vjs-lite runtimes. Enabled by default unless
--no-node-compat is passed.
import ... from "node:util"
node-compat (enabled by default; disable with --no-node-compat)Example
Section titled “Example”import { format, inspect, isDeepStrictEqual, parseArgs } from "node:util";
console.log(format("%s=%d", "count", 3));console.log(inspect({ ok: true }, { depth: 2 }));console.log(isDeepStrictEqual({ a: 1 }, { a: 1 }));const parsed = parseArgs({ args: ["--flag", "pos"], options: { flag: { type: "boolean" } } });console.log(parsed.values.flag, parsed.positionals);formatv0.0.0-alpha.2printf-style placeholders (%s, %d, %i, %f, %j, %o, %O, %c, %%).formatWithOptionsv0.0.0-alpha.2printf-style placeholders and inspectOptions.callbackifyv0.0.0-alpha.2async (or Promise-returning) function to accept an error-first callback.deprecatev0.0.0-alpha.2fn to mark it deprecated and emit a deprecation warning once with msg.inheritsv0.0.0-alpha.2superConstructor onto constructor.parseArgsv0.0.0-alpha.2styleTextv0.0.0-alpha.2format to text.stripVTControlCharactersv0.0.0-alpha.2str.isDeepStrictEqualv0.0.0-alpha.2true if val1 and val2 are strictly deeply equal.InspectOptionsv0.0.0-alpha.2inspect() and formatWithOptions() output.InspectFunctionv0.0.0-alpha.2inspect helper interface exposing inspect.custom.PromisifyFunctionv0.0.0-alpha.2promisify helper interface exposing promisify.custom.ParseArgsOptionConfigv0.0.0-alpha.2parseArgs({ options }).ParseArgsConfigv0.0.0-alpha.2parseArgs(config).ParsedArgsv0.0.0-alpha.2parseArgs().StyleTextOptionsv0.0.0-alpha.2styleText().TextDecoderOptionsv0.0.0-alpha.2new TextDecoder(label, options).TextDecodeOptionsv0.0.0-alpha.2TextDecoder.prototype.decode(input, options).UtilTypesv0.0.0-alpha.2util.types (node:util/types).Functions
Section titled “Functions”format
Section titled “format”export function format(format?: unknown, ...param: unknown[]): string;
Format a string using printf-style placeholders (%s, %d, %i, %f, %j, %o, %O, %c, %%).
| Name | Type | Description |
|---|---|---|
format optional | unknown | Format template or first value to format. |
...param | unknown[] | Additional values interpolated or appended to the output. |
string — Formatted string.formatWithOptions
Section titled “formatWithOptions”export function formatWithOptions(
inspectOptions: InspectOptions,
format?: unknown,
...param: unknown[]
): string;
Format a string using printf-style placeholders and inspectOptions.
| Name | Type | Description |
|---|---|---|
inspectOptions | InspectOptions | Inspection options applied to %o, %O, and trailing object arguments. |
format optional | unknown | Format template or first value to format. |
...param | unknown[] | Additional values interpolated or appended to the output. |
string — Formatted string.callbackify
Section titled “callbackify”export function callbackify<TArgs extends any[], TResult>(
fn: (...args: TArgs) => Promise<TResult>,
): (...args: [...TArgs, (err: unknown, result: TResult) => void]) => void;
Wrap an async (or Promise-returning) function to accept an error-first callback.
| Name | Type | Description |
|---|---|---|
fn | (...args: TArgs) => Promise<TResult> | Async function to wrap. |
(...args: [...TArgs, (err: unknown, result: TResult) => void]) => void — Callback-style wrapper function.TypeError— whenfnis not a function.
deprecate
Section titled “deprecate”export function deprecate<T extends (...args: any[]) => any>(
fn: T,
msg: string,
code?: string,
): T;
Wrap fn to mark it deprecated and emit a deprecation warning once with msg.
| Name | Type | Description |
|---|---|---|
fn | T | Function to wrap. |
msg | string | Deprecation warning message. |
code optional | string | Optional deprecation code (for example "DEP0001"). |
T — Wrapped function forwarding all arguments and this.inherits
Section titled “inherits”export function inherits(constructor: unknown, superConstructor: unknown): void;
Inherit prototype methods from superConstructor onto constructor.
| Name | Type | Description |
|---|---|---|
constructor | unknown | Subclass constructor function. |
superConstructor | unknown | Superclass constructor function. |
voidTypeError— when either argument is invalid.
parseArgs
Section titled “parseArgs”export function parseArgs(config?: ParseArgsConfig): ParsedArgs;
Parse command-line option flags and positional arguments.
| Name | Type | Description |
|---|---|---|
config optional | ParseArgsConfig | Optional argument vector, option schema, and parser flags. |
TypeError— on invalid configuration or unknown/malformed arguments in strict mode.
styleText
Section titled “styleText”export function styleText(
format: StyleTextFormat | readonly StyleTextFormat[],
text: string,
options?: StyleTextOptions,
): string;
Apply ANSI/VT formatting format to text.
| Name | Type | Description |
|---|---|---|
format | StyleTextFormat | readonly StyleTextFormat[] | Style name or array of style names. |
text | string | Input text to style. |
options optional | StyleTextOptions | Optional stream validation settings. |
string — Styled string (or text unchanged when color is disabled).stripVTControlCharacters
Section titled “stripVTControlCharacters”export function stripVTControlCharacters(str: string): string;
Remove VT / ANSI escape sequences from str.
| Name | Type | Description |
|---|---|---|
str | string | String potentially containing ANSI/VT control sequences. |
string — Plain string with control sequences stripped.TypeError— whenstris not a string.
isDeepStrictEqual
Section titled “isDeepStrictEqual”export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
Return true if val1 and val2 are strictly deeply equal.
| Name | Type | Description |
|---|---|---|
val1 | unknown | First value to compare. |
val2 | unknown | Second value to compare. |
boolean — true if deeply strictly equal, otherwise false.Classes
Section titled “Classes”TextEncoder
Section titled “TextEncoder”export class TextEncoder {
readonly encoding: "utf-8";
encode(input?: string): Uint8Array;
encodeInto(source: string, destination: Uint8Array): { read: number; written: number };
}
WHATWG UTF-8 TextEncoder implementation.
| Property | Type | Description | Since |
|---|---|---|---|
encoding readonly | "utf-8" | Always "utf-8". | v0.0.0-alpha.2 |
TextEncoder.encode
Section titled “TextEncoder.encode”encode(input?: string): Uint8Array;
Encode input as a UTF-8 Uint8Array.
| Name | Type | Description |
|---|---|---|
input optional | string | Input string (default ""). |
Uint8Array — Newly allocated UTF-8 byte array.TextEncoder.encodeInto
Section titled “TextEncoder.encodeInto”encodeInto(source: string, destination: Uint8Array): { read: number; written: number };
Encode source into the existing destination Uint8Array.
| Name | Type | Description |
|---|---|---|
source | string | Input string to encode. |
destination | Uint8Array | Destination buffer receiving UTF-8 bytes. |
{ read: number; written: number } — Object reporting UTF-16 code units read and UTF-8 bytes written.TextDecoder
Section titled “TextDecoder”export class TextDecoder {
readonly encoding: string;
readonly fatal: boolean;
readonly ignoreBOM: boolean;
constructor(label?: string, options?: TextDecoderOptions);
decode(input?: ArrayBufferView | ArrayBuffer, options?: TextDecodeOptions): string;
}
WHATWG TextDecoder implementation.
constructor(label?: string, options?: TextDecoderOptions);
Construct a TextDecoder for label (default "utf-8").
| Name | Type | Description |
|---|---|---|
label optional | string | Encoding label. |
options optional | TextDecoderOptions | Decoder options (fatal, ignoreBOM). |
RangeError— whenlabelis unsupported.
| Property | Type | Description | Since |
|---|---|---|---|
encoding readonly | string | Normalized encoding label (for example "utf-8"). | v0.0.0-alpha.2 |
fatal readonly | boolean | Whether invalid byte sequences throw TypeError. | v0.0.0-alpha.2 |
ignoreBOM readonly | boolean | Whether a leading byte order mark (BOM) is preserved. | v0.0.0-alpha.2 |
TextDecoder.decode
Section titled “TextDecoder.decode”decode(input?: ArrayBufferView | ArrayBuffer, options?: TextDecodeOptions): string;
Decode input bytes into a JavaScript string.
| Name | Type | Description |
|---|---|---|
input optional | ArrayBufferView | ArrayBuffer | Byte buffer or view to decode. |
options optional | TextDecodeOptions | Optional streaming flag. |
string — Decoded string.TypeError— whenfatalistrueand input contains invalid byte sequences.
Interfaces
Section titled “Interfaces”InspectOptions
Section titled “InspectOptions”export interface InspectOptions {
showHidden?: boolean;
depth?: number | null;
colors?: boolean;
customInspect?: boolean;
showProxy?: boolean;
maxArrayLength?: number | null;
maxStringLength?: number | null;
breakLength?: number;
compact?: boolean | number;
sorted?: boolean | ((a: string, b: string) => number);
getters?: boolean | "get" | "set";
numericSeparator?: boolean;
}
Options controlling inspect() and formatWithOptions() output.
| Property | Type | Description | Since |
|---|---|---|---|
showHidden optional | boolean | Include non-enumerable properties and symbols when true. | v0.0.0-alpha.2 |
depth optional | number | null | Maximum object recursion depth (null for unlimited). | v0.0.0-alpha.2 |
colors optional | boolean | Enable ANSI color codes in formatted output. | v0.0.0-alpha.2 |
customInspect optional | boolean | Invoke custom [inspect.custom] hooks when true (default true). | v0.0.0-alpha.2 |
showProxy optional | boolean | Show Proxy target and handler details when true. | v0.0.0-alpha.2 |
maxArrayLength optional | number | null | Maximum number of array/typed-array/collection elements to display (null for unlimited). | v0.0.0-alpha.2 |
maxStringLength optional | number | null | Maximum string length before truncation (null for unlimited). | v0.0.0-alpha.2 |
breakLength optional | number | Column width where multi-line formatting breaks. | v0.0.0-alpha.2 |
compact optional | boolean | number | Compact formatting threshold (boolean or max single-line fields). | v0.0.0-alpha.2 |
sorted optional | boolean | ((a: string, b: string) => number) | Sort object keys lexicographically when true. | v0.0.0-alpha.2 |
getters optional | boolean | "get" | "set" | Include get/set indicator for accessor properties when true. | v0.0.0-alpha.2 |
numericSeparator optional | boolean | Insert numeric separators in bigints and numbers when true. | v0.0.0-alpha.2 |
InspectFunction
Section titled “InspectFunction”export interface InspectFunction {
(object: unknown, showHidden?: boolean, depth?: number | null, color?: boolean): string;
(object: unknown, options?: InspectOptions): string;
readonly custom: symbol;
}
Callable inspect helper interface exposing inspect.custom.
(object: unknown, showHidden?: boolean, depth?: number | null, color?: boolean): string;
Format object into a human-readable diagnostic string.
| Name | Type | Description |
|---|---|---|
object | unknown | Value to inspect. |
showHidden optional | boolean | Include non-enumerable properties when true. |
depth optional | number | null | Maximum recursion depth (null for unlimited). |
color optional | boolean | Enable ANSI colors when true. |
string — Formatted representation of object.(object: unknown, options?: InspectOptions): string;
Format object into a human-readable diagnostic string using options.
| Name | Type | Description |
|---|---|---|
object | unknown | Value to inspect. |
options optional | InspectOptions | Formatting options object. |
string — Formatted representation of object.| Property | Type | Description | Since |
|---|---|---|---|
custom readonly | symbol | Symbol key allowing objects to define custom inspect() formatting. | v0.0.0-alpha.2 |
PromisifyFunction
Section titled “PromisifyFunction”export interface PromisifyFunction {
<TResult>(fn: (callback: (err: unknown, result: TResult) => void) => void): () => Promise<TResult>;
<TArgs extends any[], TResult>(
fn: (...args: [...TArgs, (err: unknown, result: TResult) => void]) => void,
): (...args: TArgs) => Promise<TResult>;
(fn: (...args: any[]) => any): (...args: any[]) => Promise<any>;
readonly custom: symbol;
}
Callable promisify helper interface exposing promisify.custom.
<TResult>(fn: (callback: (err: unknown, result: TResult) => void) => void): () => Promise<TResult>;
Convert a Node-style callback function taking no extra arguments into one returning a Promise.
| Name | Type | Description |
|---|---|---|
fn | (callback: (err: unknown, result: TResult) => void) => void | Callback-style function (callback) => void. |
() => Promise<TResult> — Function returning Promise<TResult>.<TArgs extends any[], TResult>(
fn: (...args: [...TArgs, (err: unknown, result: TResult) => void]) => void,
): (...args: TArgs) => Promise<TResult>;
Convert a Node-style callback function taking (arg1, ..., callback) into one returning a Promise.
| Name | Type | Description |
|---|---|---|
fn | (...args: [...TArgs, (err: unknown, result: TResult) => void]) => void | Callback-style function. |
(...args: TArgs) => Promise<TResult> — Function returning Promise<TResult>.(fn: (...args: any[]) => any): (...args: any[]) => Promise<any>;
Convert a custom or variadic callback function into one returning a Promise.
| Name | Type | Description |
|---|---|---|
fn | (...args: any[]) => any | Function to wrap. |
(...args: any[]) => Promise<any> — Promisified wrapper function.| Property | Type | Description | Since |
|---|---|---|---|
custom readonly | symbol | Symbol key allowing functions to provide a custom promisify() implementation. | v0.0.0-alpha.2 |
ParseArgsOptionConfig
Section titled “ParseArgsOptionConfig”export interface ParseArgsOptionConfig {
type: "string" | "boolean";
multiple?: boolean;
short?: string;
default?: string | boolean | string[] | boolean[];
}
Single option specification accepted by parseArgs({ options }).
| Property | Type | Description | Since |
|---|---|---|---|
type | "string" | "boolean" | Expected value type ("string" or "boolean"). | v0.0.0-alpha.2 |
multiple optional | boolean | Allow passing the option multiple times, returning an array of values. | v0.0.0-alpha.2 |
short optional | string | Optional single-character short alias (for example "v" for -v). | v0.0.0-alpha.2 |
default optional | string | boolean | string[] | boolean[] | Default value when the option is not supplied. | v0.0.0-alpha.2 |
ParseArgsConfig
Section titled “ParseArgsConfig”export interface ParseArgsConfig {
args?: readonly string[];
options?: Record<string, ParseArgsOptionConfig>;
strict?: boolean;
allowPositionals?: boolean;
allowNegative?: boolean;
tokens?: boolean;
}
Configuration object accepted by parseArgs(config).
| Property | Type | Description | Since |
|---|---|---|---|
args optional | readonly string[] | Argument vector to parse (defaults to process.argv.slice(2)). | v0.0.0-alpha.2 |
options optional | Record<string, ParseArgsOptionConfig> | Named option definitions keyed by long option name. | v0.0.0-alpha.2 |
strict optional | boolean | Throw on unknown options or unexpected positional arguments (default true). | v0.0.0-alpha.2 |
allowPositionals optional | boolean | Allow positional arguments (defaults to !strict or true when allowPositionals is set). | v0.0.0-alpha.2 |
allowNegative optional | boolean | Allow --no-<flag> negations for boolean options. | v0.0.0-alpha.2 |
tokens optional | boolean | Return raw ordered parse tokens alongside values and positionals. | v0.0.0-alpha.2 |
ParsedArgs
Section titled “ParsedArgs”export interface ParsedArgs {
values: Record<string, string | boolean | Array<string | boolean> | undefined>;
positionals: string[];
tokens?: ParseArgsToken[];
}
Result returned by parseArgs().
| Property | Type | Description | Since |
|---|---|---|---|
values | Record<string, string | boolean | Array<string | boolean> | undefined> | Map from option name to parsed value(s). | v0.0.0-alpha.2 |
positionals | string[] | Ordered array of positional argument strings. | v0.0.0-alpha.2 |
tokens optional | ParseArgsToken[] | Ordered parse tokens when tokens: true was requested. | v0.0.0-alpha.2 |
StyleTextOptions
Section titled “StyleTextOptions”export interface StyleTextOptions {
validateStream?: boolean;
stream?: unknown;
}
Options accepted by styleText().
| Property | Type | Description | Since |
|---|---|---|---|
validateStream optional | boolean | Validate whether the target stream supports color output. | v0.0.0-alpha.2 |
stream optional | unknown | Target output stream checked when validateStream is true. | v0.0.0-alpha.2 |
TextDecoderOptions
Section titled “TextDecoderOptions”export interface TextDecoderOptions {
fatal?: boolean;
ignoreBOM?: boolean;
}
Options accepted by new TextDecoder(label, options).
| Property | Type | Description | Since |
|---|---|---|---|
fatal optional | boolean | Throw a TypeError on invalid byte sequences instead of emitting U+FFFD. | v0.0.0-alpha.2 |
ignoreBOM optional | boolean | Preserve a leading UTF-8/UTF-16 BOM instead of stripping it. | v0.0.0-alpha.2 |
TextDecodeOptions
Section titled “TextDecodeOptions”export interface TextDecodeOptions {
stream?: boolean;
}
Options accepted by TextDecoder.prototype.decode(input, options).
| Property | Type | Description | Since |
|---|---|---|---|
stream optional | boolean | Defer incomplete multi-byte trailing sequences to the next decode() call. | v0.0.0-alpha.2 |
UtilTypes
Section titled “UtilTypes”export interface UtilTypes {
isAnyArrayBuffer(value: unknown): value is ArrayBufferLike;
isArgumentsObject(value: unknown): boolean;
isArrayBuffer(value: unknown): value is ArrayBuffer;
isArrayBufferView(value: unknown): value is ArrayBufferView;
isAsyncFunction(value: unknown): boolean;
isBigInt64Array(value: unknown): value is BigInt64Array;
isBigUint64Array(value: unknown): value is BigUint64Array;
isBooleanObject(value: unknown): boolean;
isBoxedPrimitive(value: unknown): boolean;
isDataView(value: unknown): value is DataView;
isDate(value: unknown): value is Date;
isFloat32Array(value: unknown): value is Float32Array;
isFloat64Array(value: unknown): value is Float64Array;
isGeneratorFunction(value: unknown): boolean;
isGeneratorObject(value: unknown): boolean;
isInt8Array(value: unknown): value is Int8Array;
isInt16Array(value: unknown): value is Int16Array;
isInt32Array(value: unknown): value is Int32Array;
isMap(value: unknown): value is Map<unknown, unknown>;
isMapIterator(value: unknown): boolean;
isModuleNamespaceObject(value: unknown): boolean;
isNativeError(value: unknown): value is Error;
isNumberObject(value: unknown): boolean;
isPromise(value: unknown): value is Promise<unknown>;
isProxy(value: unknown): boolean;
isRegExp(value: unknown): value is RegExp;
isSet(value: unknown): value is Set<unknown>;
isSetIterator(value: unknown): boolean;
isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer;
isStringObject(value: unknown): boolean;
isSymbolObject(value: unknown): boolean;
isTypedArray(value: unknown): value is ArrayBufferView;
isUint8Array(value: unknown): value is Uint8Array;
isUint8ClampedArray(value: unknown): value is Uint8ClampedArray;
isUint16Array(value: unknown): value is Uint16Array;
isUint32Array(value: unknown): value is Uint32Array;
isWeakMap(value: unknown): value is WeakMap<object, unknown>;
isWeakSet(value: unknown): value is WeakSet<object>;
}
Runtime type-checking predicates exposed on util.types (node:util/types).
UtilTypes.isAnyArrayBuffer
Section titled “UtilTypes.isAnyArrayBuffer”isAnyArrayBuffer(value: unknown): value is ArrayBufferLike;
Return true if value is an ArrayBuffer or SharedArrayBuffer.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is ArrayBufferLikeUtilTypes.isArgumentsObject
Section titled “UtilTypes.isArgumentsObject”isArgumentsObject(value: unknown): boolean;
Return true if value is an arguments object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isArrayBuffer
Section titled “UtilTypes.isArrayBuffer”isArrayBuffer(value: unknown): value is ArrayBuffer;
Return true if value is an ArrayBuffer.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is ArrayBufferUtilTypes.isArrayBufferView
Section titled “UtilTypes.isArrayBufferView”isArrayBufferView(value: unknown): value is ArrayBufferView;
Return true if value is an ArrayBufferView (TypedArray or DataView).
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is ArrayBufferViewUtilTypes.isAsyncFunction
Section titled “UtilTypes.isAsyncFunction”isAsyncFunction(value: unknown): boolean;
Return true if value is an async function.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isBigInt64Array
Section titled “UtilTypes.isBigInt64Array”isBigInt64Array(value: unknown): value is BigInt64Array;
Return true if value is a BigInt64Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is BigInt64ArrayUtilTypes.isBigUint64Array
Section titled “UtilTypes.isBigUint64Array”isBigUint64Array(value: unknown): value is BigUint64Array;
Return true if value is a BigUint64Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is BigUint64ArrayUtilTypes.isBooleanObject
Section titled “UtilTypes.isBooleanObject”isBooleanObject(value: unknown): boolean;
Return true if value is a boxed Boolean object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isBoxedPrimitive
Section titled “UtilTypes.isBoxedPrimitive”isBoxedPrimitive(value: unknown): boolean;
Return true if value is a boxed primitive object (Boolean, Number, String, Symbol, BigInt).
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isDataView
Section titled “UtilTypes.isDataView”isDataView(value: unknown): value is DataView;
Return true if value is a DataView.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is DataViewUtilTypes.isDate
Section titled “UtilTypes.isDate”isDate(value: unknown): value is Date;
Return true if value is a Date.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is DateUtilTypes.isFloat32Array
Section titled “UtilTypes.isFloat32Array”isFloat32Array(value: unknown): value is Float32Array;
Return true if value is a Float32Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Float32ArrayUtilTypes.isFloat64Array
Section titled “UtilTypes.isFloat64Array”isFloat64Array(value: unknown): value is Float64Array;
Return true if value is a Float64Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Float64ArrayUtilTypes.isGeneratorFunction
Section titled “UtilTypes.isGeneratorFunction”isGeneratorFunction(value: unknown): boolean;
Return true if value is a generator function.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isGeneratorObject
Section titled “UtilTypes.isGeneratorObject”isGeneratorObject(value: unknown): boolean;
Return true if value is a generator object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isInt8Array
Section titled “UtilTypes.isInt8Array”isInt8Array(value: unknown): value is Int8Array;
Return true if value is an Int8Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Int8ArrayUtilTypes.isInt16Array
Section titled “UtilTypes.isInt16Array”isInt16Array(value: unknown): value is Int16Array;
Return true if value is an Int16Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Int16ArrayUtilTypes.isInt32Array
Section titled “UtilTypes.isInt32Array”isInt32Array(value: unknown): value is Int32Array;
Return true if value is an Int32Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Int32ArrayUtilTypes.isMap
Section titled “UtilTypes.isMap”isMap(value: unknown): value is Map<unknown, unknown>;
Return true if value is a Map.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Map<unknown, unknown>UtilTypes.isMapIterator
Section titled “UtilTypes.isMapIterator”isMapIterator(value: unknown): boolean;
Return true if value is a Map iterator.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isModuleNamespaceObject
Section titled “UtilTypes.isModuleNamespaceObject”isModuleNamespaceObject(value: unknown): boolean;
Return true if value is an ES module namespace object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isNativeError
Section titled “UtilTypes.isNativeError”isNativeError(value: unknown): value is Error;
Return true if value is a native Error instance.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is ErrorUtilTypes.isNumberObject
Section titled “UtilTypes.isNumberObject”isNumberObject(value: unknown): boolean;
Return true if value is a boxed Number object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isPromise
Section titled “UtilTypes.isPromise”isPromise(value: unknown): value is Promise<unknown>;
Return true if value is a native Promise.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Promise<unknown>UtilTypes.isProxy
Section titled “UtilTypes.isProxy”isProxy(value: unknown): boolean;
Return true if value is a Proxy.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isRegExp
Section titled “UtilTypes.isRegExp”isRegExp(value: unknown): value is RegExp;
Return true if value is a RegExp.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is RegExpUtilTypes.isSet
Section titled “UtilTypes.isSet”isSet(value: unknown): value is Set<unknown>;
Return true if value is a Set.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Set<unknown>UtilTypes.isSetIterator
Section titled “UtilTypes.isSetIterator”isSetIterator(value: unknown): boolean;
Return true if value is a Set iterator.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isSharedArrayBuffer
Section titled “UtilTypes.isSharedArrayBuffer”isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer;
Return true if value is a SharedArrayBuffer.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is SharedArrayBufferUtilTypes.isStringObject
Section titled “UtilTypes.isStringObject”isStringObject(value: unknown): boolean;
Return true if value is a boxed String object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isSymbolObject
Section titled “UtilTypes.isSymbolObject”isSymbolObject(value: unknown): boolean;
Return true if value is a boxed Symbol object.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
booleanUtilTypes.isTypedArray
Section titled “UtilTypes.isTypedArray”isTypedArray(value: unknown): value is ArrayBufferView;
Return true if value is a TypedArray.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is ArrayBufferViewUtilTypes.isUint8Array
Section titled “UtilTypes.isUint8Array”isUint8Array(value: unknown): value is Uint8Array;
Return true if value is a Uint8Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Uint8ArrayUtilTypes.isUint8ClampedArray
Section titled “UtilTypes.isUint8ClampedArray”isUint8ClampedArray(value: unknown): value is Uint8ClampedArray;
Return true if value is a Uint8ClampedArray.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Uint8ClampedArrayUtilTypes.isUint16Array
Section titled “UtilTypes.isUint16Array”isUint16Array(value: unknown): value is Uint16Array;
Return true if value is a Uint16Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Uint16ArrayUtilTypes.isUint32Array
Section titled “UtilTypes.isUint32Array”isUint32Array(value: unknown): value is Uint32Array;
Return true if value is a Uint32Array.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is Uint32ArrayUtilTypes.isWeakMap
Section titled “UtilTypes.isWeakMap”isWeakMap(value: unknown): value is WeakMap<object, unknown>;
Return true if value is a WeakMap.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is WeakMap<object, unknown>UtilTypes.isWeakSet
Section titled “UtilTypes.isWeakSet”isWeakSet(value: unknown): value is WeakSet<object>;
Return true if value is a WeakSet.
| Name | Type | Description |
|---|---|---|
value | unknown | — |
value is WeakSet<object>Type Aliases
Section titled “Type Aliases”ParseArgsToken
Section titled “ParseArgsToken”export type ParseArgsToken =
| {
/** Token kind (`"option"`). @since 0.0.0-alpha.2 */
kind: "option";
/** Canonical long option name. @since 0.0.0-alpha.2 */
name: string;
/** Raw flag token as passed in `args`. @since 0.0.0-alpha.2 */
rawName: string;
/** Zero-based index in `args`. @since 0.0.0-alpha.2 */
index: number;
/** Parsed string value when `type === "string"`. @since 0.0.0-alpha.2 */
value: string | undefined;
/** Raw inline value indicator (`true` for `--foo=bar`). @since 0.0.0-alpha.2 */
inlineValue: boolean | undefined;
}
| {
/** Token kind (`"positional"`). @since 0.0.0-alpha.2 */
kind: "positional";
/** Positional argument string. @since 0.0.0-alpha.2 */
value: string;
/** Zero-based index in `args`. @since 0.0.0-alpha.2 */
index: number;
}
| {
/** Token kind (`"option-terminator"`). @since 0.0.0-alpha.2 */
kind: "option-terminator";
/** Zero-based index of `"--"` in `args`. @since 0.0.0-alpha.2 */
index: number;
};
Parsed token emitted when parseArgs({ tokens: true }) is used.
StyleTextFormat
Section titled “StyleTextFormat”export type StyleTextFormat =
| "reset"
| "bold"
| "dim"
| "italic"
| "underline"
| "blink"
| "inverse"
| "hidden"
| "strikethrough"
| "doubleunderline"
| "black"
| "red"
| "green"
| "yellow"
| "blue"
| "magenta"
| "cyan"
| "white"
| "gray"
| "grey"
| "blackBright"
| "redBright"
| "greenBright"
| "yellowBright"
| "blueBright"
| "magentaBright"
| "cyanBright"
| "whiteBright"
| "bgBlack"
| "bgRed"
| "bgGreen"
| "bgYellow"
| "bgBlue"
| "bgMagenta"
| "bgCyan"
| "bgWhite"
| "bgGray"
| "bgGrey"
| "bgBlackBright"
| "bgRedBright"
| "bgGreenBright"
| "bgYellowBright"
| "bgBlueBright"
| "bgMagentaBright"
| "bgCyanBright"
| "bgWhiteBright"
| (string & {});
Supported style names accepted by styleText().
Constants
Section titled “Constants”inspect
Section titled “inspect”export const inspect: InspectFunction;
Format any JavaScript value into a human-readable diagnostic string.
promisify
Section titled “promisify”export const promisify: PromisifyFunction;
Convert an error-first callback function into a Promise-returning function.
export const types: UtilTypes;
Runtime type-checking predicates (node:util/types).
Default Export
Section titled “Default Export”default export
Section titled “default export”const _default: {
/** Format a string using printf-style placeholders. @since 0.0.0-alpha.2 */
format: typeof format;
/** Format a string using printf-style placeholders and inspect options. @since 0.0.0-alpha.2 */
formatWithOptions: typeof formatWithOptions;
/** Format any JavaScript value into a diagnostic string. @since 0.0.0-alpha.2 */
inspect: typeof inspect;
/** Convert an error-first callback function to return a Promise. @since 0.0.0-alpha.2 */
promisify: typeof promisify;
/** Convert an async function to accept an error-first callback. @since 0.0.0-alpha.2 */
callbackify: typeof callbackify;
/** Wrap a function with a one-time deprecation warning. @since 0.0.0-alpha.2 */
deprecate: typeof deprecate;
/** Inherit prototype methods from one constructor to another. @since 0.0.0-alpha.2 */
inherits: typeof inherits;
/** Parse command-line arguments. @since 0.0.0-alpha.2 */
parseArgs: typeof parseArgs;
/** Apply ANSI/VT formatting to text. @since 0.0.0-alpha.2 */
styleText: typeof styleText;
/** Strip VT/ANSI escape sequences from a string. @since 0.0.0-alpha.2 */
stripVTControlCharacters: typeof stripVTControlCharacters;
/** WHATWG UTF-8 TextEncoder class. @since 0.0.0-alpha.2 */
TextEncoder: typeof TextEncoder;
/** WHATWG TextDecoder class. @since 0.0.0-alpha.2 */
TextDecoder: typeof TextDecoder;
/** Deep strict equality check. @since 0.0.0-alpha.2 */
isDeepStrictEqual: typeof isDeepStrictEqual;
/** Runtime type-checking predicates (`node:util/types`). @since 0.0.0-alpha.2 */
readonly types: UtilTypes;
};
export default _default;
Default export object providing all node:util helpers and classes.
