Package-level declarations

Types

Link copied to clipboard
sealed external interface BackgroundColors
Link copied to clipboard
sealed external interface CallSiteObject
Link copied to clipboard
typealias CustomInspectFunction = (depth: Number, options: InspectOptionsStylized) -> Any?
Link copied to clipboard
Link copied to clipboard
sealed external interface CustomPromisifySymbol<TCustom : Function<*>> : <ERROR CLASS> ERROR CLASS: Symbol not found for js.function.JsFunction<kotlin/Nothing, kotlin/Any?>
Link copied to clipboard
sealed external interface DebugLogger : <ERROR CLASS> ERROR CLASS: Symbol not found for js.function.JsFunction<ERROR CLASS: Symbol not found for js.array.Tuple1<kotlin/String>, kotlin/Unit>
Link copied to clipboard
Link copied to clipboard
typealias DiffEntry = ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/Int, kotlin/String>
Link copied to clipboard
sealed external interface ForegroundColors
Link copied to clipboard
sealed external interface GetCallSitesOptions
Link copied to clipboard
sealed external interface InspectOptions
Link copied to clipboard
sealed external interface InspectOptionsStylized : InspectOptions
Link copied to clipboard
external class MIMEParams

The MIMEParams API provides read and write access to the parameters of a MIMEType.

Link copied to clipboard
external class MIMEType

An implementation of the MIMEType class.

Link copied to clipboard
sealed external interface MIMETypeInput
Link copied to clipboard
sealed external interface Modifiers
Link copied to clipboard
typealias OptionToken = Any
Link copied to clipboard
sealed external interface ParseArgsConfig
Link copied to clipboard
sealed external interface ParseArgsOptionDescriptor
Link copied to clipboard
sealed external interface ParseArgsOptionsConfig
Link copied to clipboard
sealed external interface ParseArgsOptionsType

Type of argument used in {@link parseArgs}.

Link copied to clipboard
sealed external interface ParsedResults<T : ParseArgsConfig>
Link copied to clipboard
sealed external interface ParsedResultsValues
Link copied to clipboard
sealed external interface Style
Link copied to clipboard
sealed external interface StyleTextOptions
Link copied to clipboard
typealias Token = Any

Functions

Link copied to clipboard
suspend external fun aborted(signal: ERROR CLASS: Symbol not found for AbortSignal, resource: Any?): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun abortedAsync(signal: ERROR CLASS: Symbol not found for AbortSignal, resource: Any?): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

Listens to abort event on the provided signal and returns a promise that resolves when the signal is aborted. If resource is provided, it weakly references the operation's associated object, so if resource is garbage collected before the signal aborts, then returned promise shall remain pending. This prevents memory leaks in long-running or non-cancelable operations.

Link copied to clipboard
external fun callbackify(fn: () -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (callback: (err: ErrnoException) -> Unit) -> Unit

Takes an async function (or a function that returns a Promise) and returns a function following the error-first callback style, i.e. taking an (err, value) => ... callback as the last argument. In the callback, the first argument will be the rejection reason (or null if the Promise resolved), and the second argument will be the resolved value.

external fun <TResult> callbackify(fn: () -> ERROR CLASS: Symbol not found for Promise<TResult>): (callback: (err: ErrnoException, result: TResult) -> Unit) -> Unit
external fun <T1> callbackify(fn: (arg1: T1) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, TResult> callbackify(fn: (arg1: T1) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, callback: (err: ErrnoException, result: TResult) -> Unit) -> Unit
external fun <T1, T2> callbackify(fn: (arg1: T1, arg2: T2) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, arg2: T2, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, TResult> callbackify(fn: (arg1: T1, arg2: T2) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3, T4> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, T4, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3, T4, T5> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, T4, T5, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3, T4, T5, T6> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, T4, T5, T6, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) -> ERROR CLASS: Symbol not found for Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
Link copied to clipboard
external fun debuglog(section: String, callback: (DebugLoggerFunction) -> Unit = definedExternally): DebugLogger

The util.debuglog() method is used to create a function that conditionally writes debug messages to stderr based on the existence of the NODE_DEBUG environment variable. If the section name appears within the value of that environment variable, then the returned function operates similar to console.error(). If not, then the returned function is a no-op.

Link copied to clipboard
external fun <T : Function<*>> deprecate(fn: T, msg: String, code: String = definedExternally): T

The util.deprecate() method wraps fn (which may be a function or class) in such a way that it is marked as deprecated.

Link copied to clipboard
external fun diff(actual: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/String>, expected: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/String>): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<{node/util/DiffEntry=} ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/Int, kotlin/String>>
external fun diff(actual: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/String>, expected: String): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<{node/util/DiffEntry=} ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/Int, kotlin/String>>
external fun diff(actual: String, expected: ERROR CLASS: Symbol not found for js.array.ReadonlyArray<kotlin/String>): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<{node/util/DiffEntry=} ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/Int, kotlin/String>>
external fun diff(actual: String, expected: String): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<{node/util/DiffEntry=} ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/Int, kotlin/String>>

util.diff() compares two string or array values and returns an array of difference entries. It uses the Myers diff algorithm to compute minimal differences, which is the same algorithm used internally by assertion error messages.

Link copied to clipboard
external fun format(format: Any? = definedExternally, vararg param: Any?): String

The util.format() method returns a formatted string using the first argument as a printf-like format string which can contain zero or more format specifiers. Each specifier is replaced with the converted value from the corresponding argument. Supported specifiers are:

Link copied to clipboard
external fun formatWithOptions(inspectOptions: InspectOptions, format: Any? = definedExternally, vararg param: Any?): String

This function is identical to {@link format}, except in that it takes an inspectOptions argument which specifies options that are passed along to {@link inspect}.

Link copied to clipboard
external fun getCallSites(options: GetCallSitesOptions): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<node/util/CallSiteObject>

external fun getCallSites(frameCount: Number = definedExternally, options: GetCallSitesOptions = definedExternally): ERROR CLASS: Symbol not found for js.array.ReadonlyArray<node/util/CallSiteObject>

Returns an array of call site objects containing the stack of the caller function.

Link copied to clipboard
external fun getSystemErrorMap(): Map<Double, ERROR CLASS: Symbol not found for js.array.Tuple2<kotlin/String, kotlin/String>>

Returns a Map of all system error codes available from the Node.js API. The mapping between error codes and error names is platform-dependent. See Common System Errors for the names of common errors.

Link copied to clipboard
external fun getSystemErrorMessage(err: Number): String

Returns the string message for a numeric error code that comes from a Node.js API. The mapping between error codes and string messages is platform-dependent.

Link copied to clipboard
external fun getSystemErrorName(err: Number): String

Returns the string name for a numeric error code that comes from a Node.js API. The mapping between error codes and error names is platform-dependent. See Common System Errors for the names of common errors.

Link copied to clipboard
external fun inherits(constructor: Any?, superConstructor: Any?)

Usage of util.inherits() is discouraged. Please use the ES6 class and extends keywords to get language level inheritance support. Also note that the two styles are semantically incompatible.

Link copied to clipboard
external fun inspect(value: Any?): String
external fun inspect(value: Any?, options: InspectOptions = definedExternally): String

external fun inspect(value: Any?, showHidden: Boolean = definedExternally, depth: Double? = definedExternally, color: Boolean = definedExternally): String

The util.inspect() method returns a string representation of object that is intended for debugging. The output of util.inspect may change at any time and should not be depended upon programmatically. Additional options may be passed that alter the result. util.inspect() will use the constructor's name and/or Symbol.toStringTag property to make an identifiable tag for an inspected value.

Link copied to clipboard
inline fun isArray(value: Any?): Boolean
Link copied to clipboard
external fun isArrayRaw(value: Any?): Boolean

Alias for Array.isArray().

Link copied to clipboard
external fun isDeepStrictEqual(val1: Any?, val2: Any?): Boolean

Returns true if there is deep strict equality between val1 and val2. Otherwise, returns false.

Link copied to clipboard
external fun <T : ParseArgsConfig> parseArgs(config: T = definedExternally): ParsedResults<T>

Provides a higher level API for command-line argument parsing than interacting with process.argv directly. Takes a specification for the expected arguments and returns a structured object with the parsed options and positionals.

Link copied to clipboard
external fun parseEnv(content: String): {node/Dict<kotlin/String>=} ERROR CLASS: Symbol not found for Record<kotlin/String, kotlin/String>

Stability: 1.1 - Active development Given an example .env file:

Link copied to clipboard

Takes a function following the common error-first callback style, i.e. taking an (err, value) => ... callback as the last argument, and returns a version that returns promises.

external fun promisify(fn: (callback: (err: Any?) -> Unit) -> Unit): () -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <TResult> promisify(fn: (callback: (err: Any?, result: TResult) -> Unit) -> Unit): () -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun <T1> promisify(fn: (arg1: T1, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <T1, TResult> promisify(fn: (arg1: T1, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1) -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun <T1, T2> promisify(fn: (arg1: T1, arg2: T2, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1, arg2: T2) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <T1, T2, TResult> promisify(fn: (arg1: T1, arg2: T2, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1, arg2: T2) -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun <T1, T2, T3> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <T1, T2, T3, TResult> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3) -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun <T1, T2, T3, T4> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <T1, T2, T3, T4, TResult> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun <T1, T2, T3, T4, T5> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) -> ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun <T1, T2, T3, T4, T5, TResult> promisify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) -> ERROR CLASS: Symbol not found for Promise<TResult>
external fun promisify(fn: Function<*>): Function<*>
Link copied to clipboard

Returns str with any ANSI escape codes removed.

Link copied to clipboard
external fun styleText(format: Array<Any>, text: String, options: StyleTextOptions = definedExternally): String
external fun styleText(format: BackgroundColors, text: String, options: StyleTextOptions = definedExternally): String
external fun styleText(format: ForegroundColors, text: String, options: StyleTextOptions = definedExternally): String
external fun styleText(format: Modifiers, text: String, options: StyleTextOptions = definedExternally): String

This function returns a formatted text considering the format passed for printing in a terminal. It is aware of the terminal's capabilities and acts according to the configuration set via NO_COLOR, NODE_DISABLE_COLORS and FORCE_COLOR environment variables.

Link copied to clipboard
external fun toUSVString(string: String): String

Returns the string after replacing any surrogate code points (or equivalently, any unpaired surrogate code units) with the Unicode "replacement character" U+FFFD.

Link copied to clipboard
external fun transferableAbortController(): ERROR CLASS: Symbol not found for AbortController

Creates and returns an AbortController instance whose AbortSignal is marked as transferable and can be used with structuredClone() or postMessage().

Link copied to clipboard
external fun transferableAbortSignal(signal: ERROR CLASS: Symbol not found for AbortSignal): ERROR CLASS: Symbol not found for AbortSignal

Marks the given AbortSignal as transferable so that it can be used withstructuredClone() and postMessage().