Package-level declarations

Types

Link copied to clipboard
sealed external interface After

Called immediately after a promise continuation executes. This may be after a then(), catch(), or finally() handler or before an await after another await.

Link copied to clipboard
sealed external interface Before

Called before a promise continuation executes. This can be in the form of then(), catch(), or finally() handlers or an await resuming.

Link copied to clipboard

A subclass of Deserializer corresponding to the format written by DefaultSerializer.

Link copied to clipboard
external class DefaultSerializer : Serializer

A subclass of Serializer that serializes TypedArray(in particular Buffer) and DataView objects as host objects, and only stores the part of their underlying ArrayBuffers that they are referring to.

Link copied to clipboard
open external class Deserializer
Link copied to clipboard
Link copied to clipboard
external class GCProfiler

This API collects GC data in current thread.

Link copied to clipboard
sealed external interface GCProfilerResult
Link copied to clipboard
sealed external interface GCProfilerResultStatisticsItem
Link copied to clipboard
sealed external interface GCProfilerResultStatisticsItemAfterGC
Link copied to clipboard
sealed external interface GCProfilerResultStatisticsItemBeforeGC
Link copied to clipboard
sealed external interface HeapCodeStatistics
Link copied to clipboard
sealed external interface HeapInfo
Link copied to clipboard
sealed external interface HeapSnapshotOptions
Link copied to clipboard
sealed external interface HeapSpaceInfo
Link copied to clipboard
sealed external interface HeapSpaceStatistics
Link copied to clipboard
sealed external interface HeapStatistics
Link copied to clipboard
sealed external interface HookCallbacks

Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or around an await, and when the promise resolves or rejects.

Link copied to clipboard
sealed external interface Init

Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will happen if a promise is created without ever getting a continuation.

Link copied to clipboard
sealed external interface PromiseHooks
Link copied to clipboard
sealed external interface QueryObjectsCountOptions
Link copied to clipboard
sealed external interface QueryObjectsSummaryOptions
Link copied to clipboard
open external class Serializer
Link copied to clipboard
sealed external interface Settled

Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or {@link Promise.reject()}.

Link copied to clipboard
sealed external interface StartupSnapshot
Link copied to clipboard
typealias StartupSnapshotCallbackFn = (args: Any?) -> Any?

Properties

Link copied to clipboard

The promiseHooks interface can be used to track promise lifecycle events.

Link copied to clipboard

The v8.startupSnapshot interface can be used to add serialization and deserialization hooks for custom startup snapshots.

Functions

Link copied to clipboard

Returns an integer representing a version tag derived from the V8 version, command-line flags, and detected CPU features. This is useful for determining whether a vm.Script cachedData buffer is compatible with this instance of V8.

Link copied to clipboard
external fun deserialize(buffer: TypedArray<*, *, *, *>): Any?

Uses a DefaultDeserializer with default options to read a JS value from a buffer.

Link copied to clipboard

Get statistics about code and its metadata in the heap, see V8 GetHeapCodeAndMetadataStatistics API. Returns an object with the following properties:

Link copied to clipboard
external fun getHeapSnapshot(options: HeapSnapshotOptions = definedExternally): Readable

Generates a snapshot of the current V8 heap and returns a Readable Stream that may be used to read the JSON serialized representation. This JSON stream format is intended to be used with tools such as Chrome DevTools. The JSON schema is undocumented and specific to the V8 engine. Therefore, the schema may change from one version of V8 to the next.

Link copied to clipboard

Returns statistics about the V8 heap spaces, i.e. the segments which make up the V8 heap. Neither the ordering of heap spaces, nor the availability of a heap space can be guaranteed as the statistics are provided via the V8 GetHeapSpaceStatistics function and may change from one V8 version to the next.

Link copied to clipboard
external fun getHeapStatistics(): HeapInfo

Returns an object with the following properties:

Link copied to clipboard
external fun queryObjects(ctor: Function<*>): Any

This is similar to the queryObjects() console API provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain in the heap after a full garbage collection, which can be useful for memory leak regression tests. To avoid surprising results, users should avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the application.

external fun queryObjects(ctor: Function<*>, options: QueryObjectsCountOptions): Double
Link copied to clipboard
external fun serialize(value: Any?): Buffer

Uses a DefaultSerializer to serialize value into a buffer.

Link copied to clipboard
external fun setFlagsFromString(flags: String)

The v8.setFlagsFromString() method can be used to programmatically set V8 command-line flags. This method should be used with care. Changing settings after the VM has started may result in unpredictable behavior, including crashes and data loss; or it may simply do nothing.

Link copied to clipboard

The API is a no-op if --heapsnapshot-near-heap-limit is already set from the command line or the API is called more than once. limit must be a positive integer. See --heapsnapshot-near-heap-limit for more information.

Link copied to clipboard
external fun stopCoverage()

The v8.stopCoverage() method allows the user to stop the coverage collection started by NODE_V8_COVERAGE, so that V8 can release the execution count records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.

Link copied to clipboard
external fun takeCoverage()

The v8.takeCoverage() method allows the user to write the coverage started by NODE_V8_COVERAGE to disk on demand. This method can be invoked multiple times during the lifetime of the process. Each time the execution counter will be reset and a new coverage report will be written to the directory specified by NODE_V8_COVERAGE.

Link copied to clipboard
external fun writeHeapSnapshot(filename: String = definedExternally, options: HeapSnapshotOptions = definedExternally): String

Generates a snapshot of the current V8 heap and writes it to a JSON file. This file is intended to be used with tools such as Chrome DevTools. The JSON schema is undocumented and specific to the V8 engine, and may change from one version of V8 to the next.