Package-level declarations

Types

Link copied to clipboard
sealed external interface BackgroundColors
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<*>> : JsContextFunction<Void?, Nothing, Any?>
Link copied to clipboard
sealed external interface DebugLogger : JsContextFunction<Void?, JsTuple1<String>, Unit>
Link copied to clipboard
Link copied to clipboard
sealed external interface ForegroundColors
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 ParseArgsOptionConfig
Link copied to clipboard
sealed external interface ParseArgsOptionConfigType
Link copied to clipboard
sealed external interface ParseArgsOptionsConfig
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
typealias Token = Any

Properties

Link copied to clipboard
external val debug: (section: String, callback: (DebugLoggerFunction) -> Unit?) -> DebugLogger

Functions

Link copied to clipboard
suspend external fun aborted(signal: AbortSignal, resource: Any?): Void
Link copied to clipboard
external fun abortedAsync(signal: AbortSignal, resource: Any?): Promise<Void>

Listens to abort event on the provided signal and returns a promise that is fulfilled when the signal is aborted. If the passed resource is garbage collected before the signal is aborted, the returned promise shall remain pending indefinitely.

Link copied to clipboard
external fun <TResult> callbackify(fn: () -> Promise<TResult>): (callback: (err: ErrnoException, result: TResult) -> Unit) -> Unit
external fun <T1, TResult> callbackify(fn: (arg1: T1) -> Promise<TResult>): (arg1: T1, callback: (err: ErrnoException, result: TResult) -> Unit) -> Unit
external fun <T1> callbackify(fn: (arg1: T1) -> Promise<Void>): (arg1: T1, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, TResult> callbackify(fn: (arg1: T1, arg2: T2) -> Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2> callbackify(fn: (arg1: T1, arg2: T2) -> Promise<Void>): (arg1: T1, arg2: T2, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) -> Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) -> Promise<Void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: ErrnoException) -> Unit) -> Unit
external fun <T1, T2, T3, T4, TResult> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: ErrnoException?, result: TResult) -> Unit) -> Unit
external fun <T1, T2, T3, T4> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) -> Promise<Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, 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) -> 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> callbackify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) -> Promise<Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, 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) -> Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, 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) -> Promise<Void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: ErrnoException) -> Unit) -> Unit

external fun callbackify(fn: () -> Promise<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.

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_DEBUGenvironment 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 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

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 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 @@toStringTag 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
inline fun isBoolean(value: Any?): Boolean
Link copied to clipboard
external fun isBooleanRaw(value: Any?): Boolean

Returns true if the given object is a Boolean. Otherwise, returns false.

Link copied to clipboard
inline fun isBuffer(value: Any?): Boolean
Link copied to clipboard
external fun isBufferRaw(value: Any?): Boolean

Returns true if the given object is a Buffer. Otherwise, returns false.

Link copied to clipboard
inline fun isDate(value: Any?): Boolean
Link copied to clipboard
external fun isDateRaw(value: Any?): Boolean

Returns true if the given object is a Date. Otherwise, returns false.

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
inline fun isError(value: Any?): Boolean
Link copied to clipboard
external fun isErrorRaw(value: Any?): Boolean

Returns true if the given object is an Error. Otherwise, returns false.

Link copied to clipboard
external fun isFunction(value: Any?): Boolean

Returns true if the given object is a Function. Otherwise, returns false.

Link copied to clipboard
inline fun isNull(value: Any?): Boolean
Link copied to clipboard
inline fun isNullOrUndefined(value: Any?): Boolean
Link copied to clipboard
external fun isNullOrUndefinedRaw(value: Any?): Boolean

Returns true if the given object is null or undefined. Otherwise, returns false.

Link copied to clipboard
external fun isNullRaw(value: Any?): Boolean

Returns true if the given object is strictly null. Otherwise, returnsfalse.

Link copied to clipboard
inline fun isNumber(value: Any?): Boolean
Link copied to clipboard
external fun isNumberRaw(value: Any?): Boolean

Returns true if the given object is a Number. Otherwise, returns false.

Link copied to clipboard
external fun isObject(value: Any?): Boolean

Returns true if the given object is strictly an Objectand not aFunction (even though functions are objects in JavaScript). Otherwise, returns false.

Link copied to clipboard
external fun isPrimitive(value: Any?): Boolean

Returns true if the given object is a primitive type. Otherwise, returnsfalse.

Link copied to clipboard
inline fun isRegExp(value: Any?): Boolean
Link copied to clipboard
external fun isRegExpRaw(value: Any?): Boolean

Returns true if the given object is a RegExp. Otherwise, returns false.

Link copied to clipboard
inline fun isString(value: Any?): Boolean
Link copied to clipboard
external fun isStringRaw(value: Any?): Boolean

Returns true if the given object is a string. Otherwise, returns false.

Link copied to clipboard
inline fun isSymbol(value: Any?): Boolean
Link copied to clipboard
external fun isSymbolRaw(value: Any?): Boolean

Returns true if the given object is a Symbol. Otherwise, returns false.

Link copied to clipboard
inline fun isUndefined(value: Any?): Boolean
Link copied to clipboard
external fun isUndefinedRaw(value: Any?): Boolean

Returns true if the given object is undefined. Otherwise, returns false.

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

The util.log() method prints the given string to stdout with an included timestamp.

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): Any

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): () -> Promise<Void>
external fun <TResult> promisify(fn: (callback: (err: Any?, result: TResult) -> Unit) -> Unit): () -> Promise<TResult>
external fun <T1> promisify(fn: (arg1: T1, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1) -> Promise<Void>
external fun <T1, TResult> promisify(fn: (arg1: T1, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1) -> Promise<TResult>
external fun <T1, T2> promisify(fn: (arg1: T1, arg2: T2, callback: (err: Any?) -> Unit) -> Unit): (arg1: T1, arg2: T2) -> Promise<Void>
external fun <T1, T2, TResult> promisify(fn: (arg1: T1, arg2: T2, callback: (err: Any?, result: TResult) -> Unit) -> Unit): (arg1: T1, arg2: T2) -> 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) -> Promise<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) -> 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) -> Promise<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) -> 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) -> Promise<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) -> 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): String
external fun styleText(format: BackgroundColors, text: String): String
external fun styleText(format: ForegroundColors, text: String): String
external fun styleText(format: Modifiers, text: String): String

Stability: 1.1 - Active development

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

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

Link copied to clipboard

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