V8 Objects, Containers & Buffers
V8 Object, Function, Array, Map, Set, Promise, Proxy, JSON, ArrayBuffer, TypedArrays, and ValueSerializer
Generated TypeScript bindings for V8 objects, functions, arrays, ES collections, promises, proxies, binary buffers (ArrayBuffer, SharedArrayBuffer, DataView, TypedArrays), and structured serialization.
Contains 38 classes and 238 bound methods. Inherited WasmHandle base methods (ptr, isNull(), as()) are documented on Core Runtime & Realms.
ArrayBufferAllocator
class ArrayBufferAllocator extends WasmHandle
A thread-safe allocator that V8 uses to allocate ArrayBuffer's memory.
The allocator is a global V8 setting. It has to be set via
Isolate.CreateParams.
Memory allocated through this allocator by V8 is accounted for as external
memory by V8. Note that V8 keeps track of the memory for all internalized
ArrayBuffers. Responsibility for tracking external memory (using
Isolate.AdjustAmountOfExternalAllocatedMemory) is handed over to the
embedder upon externalization and taken over upon internalization (creating
an internalized buffer from an existing buffer).
Note that it is unsafe to call back into V8 from any of the allocator functions.
Upstream C++: v8::ArrayBuffer::Allocator (v8-array-buffer.h)
Static Methods
-
static newDefaultAllocator(): ArrayBufferAllocator | nullConvenience allocator.
When the sandbox is enabled, this allocator will allocate its backing memory inside the default global sandbox. Otherwise, it will rely on malloc/free.
Caller takes ownership, i.e. the returned object needs to be freed using |delete allocator| once it is no longer in use.
Upstream C++:
v8::ArrayBuffer::Allocator::NewDefaultAllocator
Methods
-
allocate(length: number): numberAllocate
lengthbytes. Returnnullif allocation is not successful. Memory should be initialized to zeroes.Upstream C++:
v8::ArrayBuffer::Allocator::Allocate -
allocateUninitialized(length: number): numberAllocate
lengthbytes. Returnnullif allocation is not successful. Memory does not have to be initialized.Upstream C++:
v8::ArrayBuffer::Allocator::AllocateUninitialized -
free(data: number, length: number): voidFree the memory block of size
length, pointed to bydata. That memory is guaranteed to be previously allocated byAllocate.Upstream C++:
v8::ArrayBuffer::Allocator::Free -
maxAllocationSize(): numberReturns a size_t that determines the largest ArrayBuffer that can be allocated. Override if your Allocator is more restrictive than the default. Will only be called once, and the value returned will be cached. Should not return a value that is larger than kMaxByteLength.
Upstream C++:
v8::ArrayBuffer::Allocator::MaxAllocationSize
ArrayBufferView
class ArrayBufferView extends V8Object
A base class for an instance of one of "views" over ArrayBuffer, including TypedArrays and DataView (ES6 draft 15.13).
Upstream C++: v8::ArrayBufferView (v8-array-buffer.h)
Static Methods
-
static fromPtr(ptr: number): ArrayBufferViewWraps a raw V8-wasm handle pointer as a
ArrayBufferView.
Methods
-
buffer(): V8ArrayBufferReturns underlying ArrayBuffer.
Upstream C++:
v8::ArrayBufferView::Buffer -
byteLength(): numberSize of a view in bytes.
Upstream C++:
v8::ArrayBufferView::ByteLength -
byteOffset(): numberByte offset in
Buffer.Upstream C++:
v8::ArrayBufferView::ByteOffset -
copyContents(dest: number, byte_length: number): numberCopy the contents of the ArrayBufferView's buffer to an embedder defined memory without additional overhead that calling
ArrayBufferView.Buffermight incur.Will write at most min(
byte_length, ByteLength) bytes starting at ByteOffset of the underlying buffer to the memory starting atdest. Returns the number of bytes actually written.Upstream C++:
v8::ArrayBufferView::CopyContents -
hasBuffer(): booleanReturns true if ArrayBufferView's backing ArrayBuffer has already been allocated.
Upstream C++:
v8::ArrayBufferView::HasBuffer
BackingStore
class BackingStore extends WasmHandle
A wrapper around the backing store (i.e. the raw memory) of an array buffer. See a document linked in http://crbug.com/v8/9908 for more information.
The allocation and destruction of backing stores is generally managed by
V8. Clients should always use standard C++ memory ownership types (i.e.
std.unique_ptr and std.shared_ptr) to manage lifetimes of backing stores
properly, since V8 internal objects may alias backing stores.
This object does not keep the underlying ArrayBuffer.Allocator alive by
default. Use Isolate.CreateParams.array_buffer_allocator_shared when
creating the Isolate to make it hold a reference to the allocator itself.
Upstream C++: v8::BackingStore (v8-array-buffer.h)
Static Methods
-
static emptyDeleter(data: number, length: number, deleter_data: number): voidIf the memory block of a BackingStore is static or is managed manually, then this empty deleter along with
nulldeleter_data can be passed toArrayBuffer.NewBackingStoreto indicate that.The manually managed case should be used with caution and only when it is guaranteed that the memory block freeing happens after detaching its ArrayBuffer.
Upstream C++:
v8::BackingStore::EmptyDeleter
Methods
-
byteLength(): numberThe length (in bytes) of this backing store.
Upstream C++:
v8::BackingStore::ByteLength -
data(): numberReturn a pointer to the beginning of the memory block for this backing store. The pointer is only valid as long as this backing store object lives.
Upstream C++:
v8::BackingStore::Data -
isImmutable(): booleanIndicates whether the backing store is immutable.
Upstream C++:
v8::BackingStore::IsImmutable -
isResizableByUserJavaScript(): booleanIndicates whether the backing store was created for a resizable ArrayBuffer or a growable SharedArrayBuffer, and thus may be resized by user JavaScript code.
Upstream C++:
v8::BackingStore::IsResizableByUserJavaScript -
isShared(): booleanIndicates whether the backing store was created for an ArrayBuffer or a SharedArrayBuffer.
Upstream C++:
v8::BackingStore::IsShared -
maxByteLength(): numberThe maximum length (in bytes) that this backing store may grow to.
If this backing store was created for a resizable ArrayBuffer or a growable SharedArrayBuffer, it is >= ByteLength(). Otherwise it is == ByteLength().
Upstream C++:
v8::BackingStore::MaxByteLength
ObjectWrappable
class ObjectWrappable extends WasmHandle
Object.Wrappable serves as the base class for all C++ objects that can
be wrapped by a JavaScript object using Object.Wrap().
Note that Object.Wrappable`` inherits from NameProviderand providesGetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
Upstream C++: v8::Object::Wrappable (v8-object.h)
Methods
-
getHumanReadableName(): string | nullBinds upstream V8 C++
v8::Object::Wrappable::GetHumanReadableName. -
getWrapperTypeInfo(): ObjectWrapperTypeInfo | nullBinds upstream V8 C++
v8::Object::Wrappable::GetWrapperTypeInfo.
ObjectWrapperTypeInfo
class ObjectWrapperTypeInfo extends WasmHandle
Type information for a Wrappable object that got wrapped with
Object.Wrap().
Upstream C++: v8::Object::WrapperTypeInfo (v8-object.h)
Private
class Private extends Data
A private symbol
This is an experimental feature. Use at your own risk.
Upstream C++: v8::Private (v8-object.h)
Static Methods
-
static forApi(isolate: Isolate, name: V8String): PrivateRetrieve a global private symbol. If a symbol with this name has not been retrieved in the same isolate before, it is created. Note that private symbols created this way are never collected, so they should only be used for statically fixed properties. Also, there is only one global name space for the names used as keys. To minimize the potential for clashes, use qualified names as keys, e.g., "Class#property".
Upstream C++:
v8::Private::ForApi -
static fromPtr(ptr: number): PrivateWraps a raw V8-wasm handle pointer as a
Private. -
static new(isolate: Isolate, name?: V8String): PrivateCreate a private symbol. If name is not empty, it will be the description.
Upstream C++:
v8::Private::New
Methods
-
name(): ValueReturns the print name string of the private symbol, or undefined if none.
Upstream C++:
v8::Private::Name
PromiseRejectMessage
class PromiseRejectMessage extends WasmHandle
Upstream V8 C++ class v8::PromiseRejectMessage (v8-promise.h).
Methods
-
getEvent(): PromiseRejectEventBinds upstream V8 C++
v8::PromiseRejectMessage::GetEvent. -
getPromise(): V8PromiseBinds upstream V8 C++
v8::PromiseRejectMessage::GetPromise. -
getValue(): ValueBinds upstream V8 C++
v8::PromiseRejectMessage::GetValue.
PromiseResolver
class PromiseResolver extends V8Object
Upstream V8 C++ class v8::Promise::Resolver (v8-promise.h).
Static Methods
-
static fromPtr(ptr: number): PromiseResolverWraps a raw V8-wasm handle pointer as a
PromiseResolver. -
static new(context: Context): MaybeLocal<PromiseResolver>Create a new resolver, along with an associated promise in pending state.
Upstream C++:
v8::Promise::Resolver::New
Methods
-
getPromise(): V8PromiseExtract the associated promise.
Upstream C++:
v8::Promise::Resolver::GetPromise -
reject(context: Context, value: Value): Maybe<boolean>Binds upstream V8 C++
v8::Promise::Resolver::Reject. -
resolve(context: Context, value: Value): Maybe<boolean>Resolve/reject the associated promise with a given value. Ignored if the promise is no longer pending.
Upstream C++:
v8::Promise::Resolver::Resolve
PropertyDescriptor
class PropertyDescriptor extends WasmHandle
An instance of a Property Descriptor, see Ecma-262 6.2.4.
Properties in a descriptor are present or absent. If you do not set
enumerable, configurable, and writable, they are absent. If value,
get, or set are absent, but you must specify them in the constructor, use
empty handles.
Accessors get and set must be callable or undefined if they are present.
Note: Only query properties if they are present, i.e., call x() only if
has_x() returns true.
// var desc = {writable: false}
v8::PropertyDescriptor d(Local<Value>()), false);
d.value(); // error, value not set
if (d.has_writable()) {
d.writable(); // false
}
// var desc = {value: undefined}
v8::PropertyDescriptor d(v8::Undefined(isolate));
// var desc = {get: undefined}
v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>()));Upstream C++: v8::PropertyDescriptor (v8-object.h)
Methods
-
configurable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::configurable. -
enumerable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::enumerable. -
get(): ValueBinds upstream V8 C++
v8::PropertyDescriptor::get. -
has_configurable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_configurable. -
has_enumerable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_enumerable. -
has_get(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_get. -
has_set(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_set. -
has_value(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_value. -
has_writable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::has_writable. -
set(): ValueBinds upstream V8 C++
v8::PropertyDescriptor::set. -
set_configurable(configurable: boolean): voidBinds upstream V8 C++
v8::PropertyDescriptor::set_configurable. -
set_enumerable(enumerable: boolean): voidBinds upstream V8 C++
v8::PropertyDescriptor::set_enumerable. -
value(): ValueBinds upstream V8 C++
v8::PropertyDescriptor::value. -
writable(): booleanBinds upstream V8 C++
v8::PropertyDescriptor::writable.
SharedValueConveyor
class SharedValueConveyor extends WasmHandle
A move-only class for managing the lifetime of shared value conveyors used by V8 to keep JS shared values alive in transit when serialized.
This class is not directly constructible and is always passed to a
ValueSerializer.Delegate via ValueSerializer.SetSharedValueConveyor.
The embedder must not destruct the SharedValueConveyor until the associated serialized data will no longer be deserialized.
Upstream C++: v8::SharedValueConveyor (v8-value-serializer.h)
TypedArray
class TypedArray extends ArrayBufferView
A base class for an instance of TypedArray series of constructors (ES6 draft 15.13.6).
Upstream C++: v8::TypedArray (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): TypedArrayWraps a raw V8-wasm handle pointer as a
TypedArray.
Methods
-
length(): numberNumber of elements in this typed array (e.g. for Int16Array,
ByteLength/2).Upstream C++:
v8::TypedArray::Length
V8Array
class V8Array extends V8Object
An instance of the built-in array constructor (ECMA-262, 15.4.2).
Upstream C++: v8::Array (v8-container.h)
Static Methods
-
static fromPtr(ptr: number): V8ArrayWraps a raw V8-wasm handle pointer as a
V8Array. -
static new(isolate: Isolate, length: number): V8ArrayCreates a JavaScript array with the given length. If the length is negative the returned array will have length 0.
Upstream C++:
v8::Array::New -
static new2(isolate: Isolate, elements: Value[], length: number): V8ArrayCreates a JavaScript array out of a
Valuearray in C++ with a known length.Upstream C++:
v8::Array::New
Methods
-
length(): numberBinds upstream V8 C++
v8::Array::Length.
V8ArrayBuffer
class V8ArrayBuffer extends V8Object
An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
Upstream C++: v8::ArrayBuffer (v8-array-buffer.h)
Static Methods
-
static fromPtr(ptr: number): V8ArrayBufferWraps a raw V8-wasm handle pointer as a
V8ArrayBuffer. -
static maybeNew(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode): MaybeLocal<V8ArrayBuffer>Attempt to create a new ArrayBuffer. Allocate
byte_lengthbytes. Allocated memory will be owned by a created ArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized. If allocation fails, the Maybe returned will be empty.Upstream C++:
v8::ArrayBuffer::MaybeNew -
static new(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode): V8ArrayBufferCreate a new ArrayBuffer. Allocate
byte_lengthbytes, which are either zero-initialized or uninitialized. Allocated memory will be owned by a created ArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized.Upstream C++:
v8::ArrayBuffer::New -
static new2(isolate: Isolate, backing_store: BackingStoreShared): V8ArrayBufferCreate a new ArrayBuffer with an existing backing store. The created array keeps a reference to the backing store until the array is garbage collected. Note that the IsExternal bit does not affect this reference from the array to the backing store.
In future IsExternal bit will be removed. Until then the bit is set as follows. If the backing store does not own the underlying buffer, then the array is created in externalized state. Otherwise, the array is created in internalized state. In the latter case the array can be transitioned to the externalized state using Externalize(backing_store).
Upstream C++:
v8::ArrayBuffer::New -
static newBackingStore(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode, on_failure: BackingStoreOnFailureMode): BackingStoreReturns a new standalone BackingStore that is allocated using the array buffer allocator of the isolate. The allocation can either be zero initialized, or uninitialized. The result can be later passed to
ArrayBuffer.New.If the allocator returns
null, then the function may cause GCs in the given isolate and re-try the allocation.If GCs do not help and on_failure is kOutOfMemory, then the function will crash with an out-of-memory error.
Otherwise if GCs do not help (or the allocation is too large for GCs to help) and on_failure is kReturnNull, then a null result is returned.
Upstream C++:
v8::ArrayBuffer::NewBackingStore -
static newResizableBackingStore(byte_length: number, max_byte_length: number): BackingStoreReturns a new resizable standalone BackingStore that is allocated using the array buffer allocator of the isolate. The result can be later passed to
ArrayBuffer.New.byte_lengthmust be <=max_byte_length.This function is usable without an isolate. Unlike
NewBackingStorecalls with an isolate, GCs cannot be triggered, and there are no retries. Allocation failure will cause the function to crash with an out-of-memory error.Upstream C++:
v8::ArrayBuffer::NewResizableBackingStore
Methods
-
byteLength(): numberData length in bytes.
Upstream C++:
v8::ArrayBuffer::ByteLength -
copyArrayBufferBytes(source_start: number, bytes_to_copy: number, target: V8ArrayBuffer, target_start: number): numberCopy up to
bytes_to_copybytes from this ArrayBuffer starting at positionsource_startto the target ArrayBuffer starting at positiontarget_start. Nothing is copied if the source or target ArrayBuffer is detached. Returns the number of bytes actually copied.Upstream C++:
v8::ArrayBuffer::CopyArrayBufferBytes -
data(): numberMore efficient shortcut for GetBackingStore()->Data(). The returned pointer is valid as long as the ArrayBuffer is alive.
Upstream C++:
v8::ArrayBuffer::Data -
detach(): voidDetaches this ArrayBuffer and all its views (typed arrays). Detaching sets the byte length of the buffer and all typed arrays to zero, preventing JavaScript from ever accessing underlying backing store. ArrayBuffer should have been externalized and must be detachable. Returns Nothing if the key didn't pass the [[ArrayBufferDetachKey]] check, Just(true) otherwise.
Upstream C++:
v8::ArrayBuffer::Detach -
detach2(key: Value): Maybe<boolean>Detaches this ArrayBuffer and all its views (typed arrays). Detaching sets the byte length of the buffer and all typed arrays to zero, preventing JavaScript from ever accessing underlying backing store. ArrayBuffer should have been externalized and must be detachable. Returns Nothing if the key didn't pass the [[ArrayBufferDetachKey]] check, Just(true) otherwise.
Upstream C++:
v8::ArrayBuffer::Detach -
getBackingStore(): BackingStoreSharedGet a shared pointer to the backing store of this array buffer. This pointer coordinates the lifetime management of the internal storage with any live ArrayBuffers on the heap, even across isolates. The embedder should not attempt to manage lifetime of the storage through other means.
The returned shared pointer will not be empty, even if the ArrayBuffer has been detached. Use
WasDetachedto tell if it has been detached instead.Upstream C++:
v8::ArrayBuffer::GetBackingStore -
isDetachable(): booleanReturns true if this ArrayBuffer may be detached.
Upstream C++:
v8::ArrayBuffer::IsDetachable -
isImmutable(): booleanReturns true if this ArrayBuffer is immutable.
Upstream C++:
v8::ArrayBuffer::IsImmutable -
isResizableByUserJavaScript(): booleanMore efficient shortcut for GetBackingStore()->IsResizableByUserJavaScript().
Upstream C++:
v8::ArrayBuffer::IsResizableByUserJavaScript -
maxByteLength(): numberMaximum length in bytes.
Upstream C++:
v8::ArrayBuffer::MaxByteLength -
setDetachKey(key: Value): voidSets the ArrayBufferDetachKey.
Upstream C++:
v8::ArrayBuffer::SetDetachKey -
wasDetached(): booleanReturns true if this ArrayBuffer has been detached.
Upstream C++:
v8::ArrayBuffer::WasDetached
V8BigInt64Array
class V8BigInt64Array extends TypedArray
An instance of BigInt64Array constructor.
Upstream C++: v8::BigInt64Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8BigInt64ArrayWraps a raw V8-wasm handle pointer as a
V8BigInt64Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8BigInt64ArrayBinds upstream V8 C++
v8::BigInt64Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8BigInt64ArrayBinds upstream V8 C++
v8::BigInt64Array::New.
V8BigUint64Array
class V8BigUint64Array extends TypedArray
An instance of BigUint64Array constructor.
Upstream C++: v8::BigUint64Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8BigUint64ArrayWraps a raw V8-wasm handle pointer as a
V8BigUint64Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8BigUint64ArrayBinds upstream V8 C++
v8::BigUint64Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8BigUint64ArrayBinds upstream V8 C++
v8::BigUint64Array::New.
V8DataView
class V8DataView extends ArrayBufferView
An instance of DataView constructor (ES6 draft 15.13.7).
Upstream C++: v8::DataView (v8-array-buffer.h)
Static Methods
-
static fromPtr(ptr: number): V8DataViewWraps a raw V8-wasm handle pointer as a
V8DataView. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8DataViewBinds upstream V8 C++
v8::DataView::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8DataViewBinds upstream V8 C++
v8::DataView::New.
V8Float16Array
class V8Float16Array extends TypedArray
An instance of Float16Array constructor.
Upstream C++: v8::Float16Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Float16ArrayWraps a raw V8-wasm handle pointer as a
V8Float16Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Float16ArrayBinds upstream V8 C++
v8::Float16Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Float16ArrayBinds upstream V8 C++
v8::Float16Array::New.
V8Float32Array
class V8Float32Array extends TypedArray
An instance of Float32Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Float32Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Float32ArrayWraps a raw V8-wasm handle pointer as a
V8Float32Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Float32ArrayBinds upstream V8 C++
v8::Float32Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Float32ArrayBinds upstream V8 C++
v8::Float32Array::New.
V8Float64Array
class V8Float64Array extends TypedArray
An instance of Float64Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Float64Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Float64ArrayWraps a raw V8-wasm handle pointer as a
V8Float64Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Float64ArrayBinds upstream V8 C++
v8::Float64Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Float64ArrayBinds upstream V8 C++
v8::Float64Array::New.
V8Function
class V8Function extends V8Object
A JavaScript function object (ECMA-262, 15.3).
Upstream C++: v8::Function (v8-function.h)
Static Methods
-
static fromPtr(ptr: number): V8FunctionWraps a raw V8-wasm handle pointer as a
V8Function.
Methods
-
call(isolate: Isolate, context: Context, recv: Value, argc: number, argv: Value[]): MaybeLocal<Value>Binds upstream V8 C++
v8::Function::Call. -
call2(context: Context, recv: Value, argc: number, argv: Value[]): MaybeLocal<Value>Binds upstream V8 C++
v8::Function::Call. -
experimental_IsNopFunction(): booleanReturns true if the function does nothing. The function returns false on error. Note that this function is experimental. Embedders should not rely on this existing. We may remove this function in the future.
Upstream C++:
v8::Function::Experimental_IsNopFunction -
functionProtoToString(context: Context): MaybeLocal<V8String>Calls builtin Function.prototype.toString on this function. This is different from
Value.ToString()that may call a user-defined toString() function, and different thanObject.ObjectProtoToString()which always serializes "[object Function]".Upstream C++:
v8::Function::FunctionProtoToString -
getBoundFunction(): ValueReturns the original function if this function is bound, else returns
Undefined.Upstream C++:
v8::Function::GetBoundFunction -
getDebugName(): ValuedisplayName if it is set, otherwise name if it is configured, otherwise function name, otherwise inferred name.
Upstream C++:
v8::Function::GetDebugName -
getInferredName(): ValueName inferred from variable or property assignment of this function. Used to facilitate debugging and profiling of JavaScript code written in an OO style, where many functions are anonymous but are assigned to object properties.
Upstream C++:
v8::Function::GetInferredName -
getName(): ValueBinds upstream V8 C++
v8::Function::GetName. -
getScriptColumnNumber(): numberReturns zero based column number of function body and kLineOffsetNotFound if no information available.
Upstream C++:
v8::Function::GetScriptColumnNumber -
getScriptLineNumber(): numberReturns zero based line number of function body and kLineOffsetNotFound if no information available.
Upstream C++:
v8::Function::GetScriptLineNumber -
getScriptStartPosition(): numberReturns zero based start position (character offset) of function body and kLineOffsetNotFound if no information available.
Upstream C++:
v8::Function::GetScriptStartPosition -
newInstance(context: Context, argc: number, argv: Value[]): MaybeLocal<V8Object>Binds upstream V8 C++
v8::Function::NewInstance. -
newInstance2(context: Context): MaybeLocal<V8Object>Binds upstream V8 C++
v8::Function::NewInstance. -
newInstanceWithSideEffectType(context: Context, argc: number, argv: Value[], side_effect_type: SideEffectType): MaybeLocal<V8Object>When side effect checks are enabled, passing kHasNoSideEffect allows the constructor to be invoked without throwing. Calls made within the constructor are still checked.
Upstream C++:
v8::Function::NewInstanceWithSideEffectType -
scriptId(): numberReturns scriptId.
Upstream C++:
v8::Function::ScriptId -
setName(name: V8String): voidBinds upstream V8 C++
v8::Function::SetName.
V8Int16Array
class V8Int16Array extends TypedArray
An instance of Int16Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Int16Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Int16ArrayWraps a raw V8-wasm handle pointer as a
V8Int16Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Int16ArrayBinds upstream V8 C++
v8::Int16Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Int16ArrayBinds upstream V8 C++
v8::Int16Array::New.
V8Int32Array
class V8Int32Array extends TypedArray
An instance of Int32Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Int32Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Int32ArrayWraps a raw V8-wasm handle pointer as a
V8Int32Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Int32ArrayBinds upstream V8 C++
v8::Int32Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Int32ArrayBinds upstream V8 C++
v8::Int32Array::New.
V8Int8Array
class V8Int8Array extends TypedArray
An instance of Int8Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Int8Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Int8ArrayWraps a raw V8-wasm handle pointer as a
V8Int8Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Int8ArrayBinds upstream V8 C++
v8::Int8Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Int8ArrayBinds upstream V8 C++
v8::Int8Array::New.
V8JSON
class V8JSON extends WasmHandle
A JSON Parser and Stringifier.
Upstream C++: v8::JSON (v8-json.h)
Static Methods
-
static stringify(context: Context, json_object: Value, gap?: V8String): MaybeLocal<V8String>Tries to stringify the JSON-serializable object
json_objectand returns it as string if successful.json_object: The JSON-serializable object to stringify. Returns: The corresponding string if successfully stringified.
Upstream C++:
v8::JSON::Stringify
V8Map
class V8Map extends V8Object
An instance of the built-in Map constructor (ECMA-262, 6th Edition, 23.1.1).
Upstream C++: v8::Map (v8-container.h)
Static Methods
-
static fromPtr(ptr: number): V8MapWraps a raw V8-wasm handle pointer as a
V8Map. -
static new(isolate: Isolate): V8MapCreates a new empty Map.
Upstream C++:
v8::Map::New
Methods
-
asArray(): V8ArrayReturns an array of length Size() * 2, where index N is the Nth key and index N + 1 is the Nth value.
Upstream C++:
v8::Map::AsArray -
clear(): voidBinds upstream V8 C++
v8::Map::Clear. -
delete(context: Context, key: Value): Maybe<boolean>Binds upstream V8 C++
v8::Map::Delete. -
get(context: Context, key: Value): MaybeLocal<Value>Binds upstream V8 C++
v8::Map::Get. -
has(context: Context, key: Value): Maybe<boolean>Binds upstream V8 C++
v8::Map::Has. -
mapSet(context: Context, key: Value, value: Value): MaybeLocal<V8Map>Binds upstream V8 C++
v8::Map::Set. -
size(): numberBinds upstream V8 C++
v8::Map::Size.
V8Object
class V8Object extends Value
A JavaScript object (ECMA-262, 4.3.3)
Upstream C++: v8::Object (v8-object.h)
Static Methods
-
static fromPtr(ptr: number): V8ObjectWraps a raw V8-wasm handle pointer as a
V8Object. -
static new2Object(isolate: Isolate, prototype_or_null: Value, names: Name[], values: Value[], length: number): V8ObjectCreates a JavaScript object with the given properties, and a the given prototype_or_null (which can be any JavaScript value, and if it's null, the newly created object won't have a prototype at all). This is similar to Object.create(). All properties will be created as enumerable, configurable and writable properties.
Upstream C++:
v8::Object::New -
static newObject(isolate: Isolate): V8ObjectCreates a JavaScript object with the given properties, and a the given prototype_or_null (which can be any JavaScript value, and if it's null, the newly created object won't have a prototype at all). This is similar to Object.create(). All properties will be created as enumerable, configurable and writable properties.
Upstream C++:
v8::Object::New -
static wrap(isolate: Isolate, wrapper: V8Object, wrappable: ObjectWrappable, tag: CppHeapPointerTag): voidBinds upstream V8 C++
v8::Object::Wrap. -
static wrapGlobal(isolate: Isolate, wrapper: V8Object, wrappable: ObjectWrappable, tag: CppHeapPointerTag): voidVersion of Wrap() function for
Context.Global()objects. Unlike the functions above it wraps both JSGlobalProxy and its hidden prototype (JSGlobalObject or remote object).Upstream C++:
v8::Object::WrapGlobal
Methods
-
callAsConstructor(context: Context, argc: number, argv: Value[]): MaybeLocal<Value>Call an Object as a constructor if a callback is set by the
ObjectTemplate.SetCallAsFunctionHandlermethod. Note: This method behaves like theFunction.NewInstancemethod.Upstream C++:
v8::Object::CallAsConstructor -
callAsFunction(context: Context, recv: Value, argc: number, argv: Value[]): MaybeLocal<Value>Call an Object as a function if a callback is set by the
ObjectTemplate.SetCallAsFunctionHandlermethod.Upstream C++:
v8::Object::CallAsFunction -
clone(isolate: Isolate): V8ObjectClone this object with a fast but shallow copy. Values will point to the same values as the original object.
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::Clone -
clone2(): V8ObjectClone this object with a fast but shallow copy. Values will point to the same values as the original object.
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::Clone -
createDataProperty(context: Context, key: Name, value: Value): Maybe<boolean>Implements CreateDataProperty(O, P, V), see https://tc39.es/ecma262/#sec-createdataproperty.
Defines a configurable, writable, enumerable property with the given value on the object unless the property already exists and is not configurable or the object is not extensible.
Returns true on success.
Upstream C++:
v8::Object::CreateDataProperty -
createDataProperty2(context: Context, index: number, value: Value): Maybe<boolean>Implements CreateDataProperty(O, P, V), see https://tc39.es/ecma262/#sec-createdataproperty.
Defines a configurable, writable, enumerable property with the given value on the object unless the property already exists and is not configurable or the object is not extensible.
Returns true on success.
Upstream C++:
v8::Object::CreateDataProperty -
defineOwnProperty(context: Context, key: Name, value: Value, attributes: PropertyAttribute): Maybe<boolean>Implements [[DefineOwnProperty]] for data property case, see https://tc39.es/ecma262/#table-essential-internal-methods.
In general, CreateDataProperty will be faster, however, does not allow for specifying attributes.
Returns true on success.
Upstream C++:
v8::Object::DefineOwnProperty -
defineProperty(context: Context, key: Name, descriptor: PropertyDescriptor): Maybe<boolean>Implements Object.defineProperty(O, P, Attributes), see https://tc39.es/ecma262/#sec-object.defineproperty.
The defineProperty function is used to add an own property or update the attributes of an existing own property of an object.
Both data and accessor descriptors can be used.
In general, CreateDataProperty is faster, however, does not allow for specifying attributes or an accessor descriptor.
The PropertyDescriptor can change when redefining a property.
Returns true on success.
Upstream C++:
v8::Object::DefineProperty -
delete(context: Context, key: Value): Maybe<boolean>Binds upstream V8 C++
v8::Object::Delete. -
delete2(context: Context, index: number): Maybe<boolean>Binds upstream V8 C++
v8::Object::Delete. -
deletePrivate(context: Context, key: Private): Maybe<boolean>Binds upstream V8 C++
v8::Object::DeletePrivate. -
findInstanceInPrototypeChain(tmpl: FunctionTemplate): V8ObjectFinds an instance of the given function template in the prototype chain.
Upstream C++:
v8::Object::FindInstanceInPrototypeChain -
get(context: Context, key: Value): MaybeLocal<Value>Binds upstream V8 C++
v8::Object::Get. -
get2(context: Context, key: Value, receiver: MaybeLocal<V8Object>): MaybeLocal<Value>Binds upstream V8 C++
v8::Object::Get. -
get3(context: Context, index: number): MaybeLocal<Value>Binds upstream V8 C++
v8::Object::Get. -
getAlignedPointerFromEmbedderDataInCreationContext(isolate: Isolate, index: number, tag: number): numberGets the context in which the object was created (see GetCreationContext()) and if it's available reads respective embedder field value. If the context can't be obtained
nullis returned. Basically it's a shortcut for obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index) which doesn't create a handle for Context object on the way and doesn't try to expand the embedder data attached to the context. In case theContextis already available because of other reasons, it's fine to keep usingContext.GetAlignedPointerFromEmbedderData().Prefer using version with Isolate parameter if you have an Isolate, otherwise use the other one.
The type tag has to match the type tag used for storing the value in the embedder field. If type tags are not used in the embedder, the default value
kEmbedderDataTypeTagDefaultcan be used.Upstream C++:
v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext -
getAlignedPointerFromEmbedderDataInCreationContext2(index: number, tag: number): numberGets the context in which the object was created (see GetCreationContext()) and if it's available reads respective embedder field value. If the context can't be obtained
nullis returned. Basically it's a shortcut for obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index) which doesn't create a handle for Context object on the way and doesn't try to expand the embedder data attached to the context. In case theContextis already available because of other reasons, it's fine to keep usingContext.GetAlignedPointerFromEmbedderData().Prefer using version with Isolate parameter if you have an Isolate, otherwise use the other one.
The type tag has to match the type tag used for storing the value in the embedder field. If type tags are not used in the embedder, the default value
kEmbedderDataTypeTagDefaultcan be used.Upstream C++:
v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext -
getAlignedPointerFromEmbedderDataInCreationContext3(isolate: Isolate, index: number, tag: CppHeapPointerTag): numberGets the context in which the object was created (see GetCreationContext()) and if it's available reads respective embedder field value. If the context can't be obtained
nullis returned. Basically it's a shortcut for obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index) which doesn't create a handle for Context object on the way and doesn't try to expand the embedder data attached to the context. In case theContextis already available because of other reasons, it's fine to keep usingContext.GetAlignedPointerFromEmbedderData().Prefer using version with Isolate parameter if you have an Isolate, otherwise use the other one.
The type tag has to match the type tag used for storing the value in the embedder field. If type tags are not used in the embedder, the default value
kEmbedderDataTypeTagDefaultcan be used.Upstream C++:
v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext -
getAlignedPointerFromInternalField(index: number, tag: number): numberGets a 2-byte-aligned native pointer from an internal field. This field must have been set by SetAlignedPointerInInternalField, everything else leads to undefined behavior.
Upstream C++:
v8::Object::GetAlignedPointerFromInternalField -
getAlignedPointerFromInternalField2(isolate: Isolate, index: number, tag: number): numberGets a 2-byte-aligned native pointer from an internal field. This field must have been set by SetAlignedPointerInInternalField, everything else leads to undefined behavior.
Upstream C++:
v8::Object::GetAlignedPointerFromInternalField -
getConstructorName(): V8StringReturns the name of the function invoked as a constructor for this object.
Upstream C++:
v8::Object::GetConstructorName -
getCreationContext(isolate: Isolate): MaybeLocal<Context>Returns the context in which the object was created.
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::GetCreationContext -
getCreationContext2(): MaybeLocal<Context>Returns the context in which the object was created.
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::GetCreationContext -
getCreationContextChecked(isolate: Isolate): ContextShortcut for GetCreationContext(...).ToLocalChecked().
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::GetCreationContextChecked -
getCreationContextChecked2(): ContextShortcut for GetCreationContext(...).ToLocalChecked().
Prefer using version with Isolate parameter.
Upstream C++:
v8::Object::GetCreationContextChecked -
getIdentityHash(): numberReturns the identity hash for this object. The current implementation uses a hidden property on the object to store the identity hash.
The return value will never be 0. Also, it is not guaranteed to be unique.
Upstream C++:
v8::Object::GetIdentityHash -
getInternalField(index: number): DataGets the data from an internal field. To cast the return value into
Valuesubtypes, it needs to be casted to aValuefirst. For example, to cast it intoExternal:object->GetInternalField(index).
As<Value>().As<External>();The embedder should make sure that the internal field being retrieved using this method has already been set with SetInternalField() before.
Upstream C++:
v8::Object::GetInternalField -
getOwnPropertyDescriptor(context: Context, key: Name): MaybeLocal<Value>Implements Object.getOwnPropertyDescriptor(O, P), see https://tc39.es/ecma262/#sec-object.getownpropertydescriptor.
Upstream C++:
v8::Object::GetOwnPropertyDescriptor -
getOwnPropertyNames(context: Context): MaybeLocal<V8Array>This function has the same functionality as GetPropertyNames but the returned array doesn't contain the names of properties from prototype objects.
Upstream C++:
v8::Object::GetOwnPropertyNames -
getOwnPropertyNames2(context: Context, filter: PropertyFilter, key_conversion: KeyConversionMode): MaybeLocal<V8Array>Returns an array containing the names of the filtered properties of this object, including properties from prototype objects. The array returned by this method contains the same values as would be enumerated by a for-in statement over this object.
Upstream C++:
v8::Object::GetOwnPropertyNames -
getPrivate(context: Context, key: Private): MaybeLocal<Value>Binds upstream V8 C++
v8::Object::GetPrivate. -
getPropertyAttributes(context: Context, key: Value): Maybe<PropertyAttribute>Gets the property attributes of a property which can be None or any combination of ReadOnly, DontEnum and DontDelete. Returns None when the property doesn't exist.
This method will be deprecated soon, since it doesn't provide a way to return "property does not exist" result. Use GetPropertyAttributes with PropertyAttribute* instead.
Upstream C++:
v8::Object::GetPropertyAttributes -
getPropertyNames(context: Context): MaybeLocal<V8Array>Returns an array containing the names of the enumerable properties of this object, including properties from prototype objects. The array returned by this method contains the same values as would be enumerated by a for-in statement over this object.
Upstream C++:
v8::Object::GetPropertyNames -
getPropertyNames2(context: Context, mode: KeyCollectionMode, property_filter: PropertyFilter, index_filter: IndexFilter, key_conversion: KeyConversionMode): MaybeLocal<V8Array>Returns an array containing the names of the enumerable properties of this object, including properties from prototype objects. The array returned by this method contains the same values as would be enumerated by a for-in statement over this object.
Upstream C++:
v8::Object::GetPropertyNames -
getPrototype(): ValueGet the prototype object (same as calling Object.getPrototypeOf(..)). This does not consult the security handler.
Upstream C++:
v8::Object::GetPrototype -
getRealNamedProperty(context: Context, key: Name): MaybeLocal<Value>If result.IsEmpty() no real property was located on the object or in the prototype chain. This means interceptors in the prototype chain are not called.
Upstream C++:
v8::Object::GetRealNamedProperty -
getRealNamedPropertyAttributes(context: Context, key: Name): Maybe<PropertyAttribute>Gets the property attributes of a real property which can be None or any combination of ReadOnly, DontEnum and DontDelete. Interceptors in the prototype chain are not called.
Upstream C++:
v8::Object::GetRealNamedPropertyAttributes -
getRealNamedPropertyAttributesInPrototypeChain(context: Context, key: Name): Maybe<PropertyAttribute>Gets the property attributes of a real property in the prototype chain, which can be None or any combination of ReadOnly, DontEnum and DontDelete. Interceptors in the prototype chain are not called.
Upstream C++:
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain -
getRealNamedPropertyInPrototypeChain(context: Context, key: Name): MaybeLocal<Value>If result.IsEmpty() no real property was located in the prototype chain. This means interceptors in the prototype chain are not called.
Upstream C++:
v8::Object::GetRealNamedPropertyInPrototypeChain -
has(context: Context, key: Value): Maybe<boolean>Object.Has()calls the abstract operation HasProperty(O, P), see https://tc39.es/ecma262/#sec-hasproperty. Has() returns true, if the object has the property, either own or on the prototype chain. Interceptors, i.e., PropertyQueryCallbacks, are called if present.Has() has the same side effects as JavaScript's
variable in object. For example, calling Has() on a revoked proxy will throw an exception.Note: Has() converts the key to a name, which possibly calls back into JavaScript.
See also
Object.HasOwnProperty()andObject.HasRealNamedProperty().Upstream C++:
v8::Object::Has -
has2(context: Context, index: number): Maybe<boolean>Object.Has()calls the abstract operation HasProperty(O, P), see https://tc39.es/ecma262/#sec-hasproperty. Has() returns true, if the object has the property, either own or on the prototype chain. Interceptors, i.e., PropertyQueryCallbacks, are called if present.Has() has the same side effects as JavaScript's
variable in object. For example, calling Has() on a revoked proxy will throw an exception.Note: Has() converts the key to a name, which possibly calls back into JavaScript.
See also
Object.HasOwnProperty()andObject.HasRealNamedProperty().Upstream C++:
v8::Object::Has -
hasIndexedLookupInterceptor(): booleanTests for an index lookup interceptor.
Upstream C++:
v8::Object::HasIndexedLookupInterceptor -
hasNamedLookupInterceptor(): booleanTests for a named lookup interceptor.
Upstream C++:
v8::Object::HasNamedLookupInterceptor -
hasOwnProperty(context: Context, key: Name): Maybe<boolean>HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
See also
Object.Has()andObject.HasRealNamedProperty().Upstream C++:
v8::Object::HasOwnProperty -
hasOwnProperty2(context: Context, index: number): Maybe<boolean>HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
See also
Object.Has()andObject.HasRealNamedProperty().Upstream C++:
v8::Object::HasOwnProperty -
hasPrivate(context: Context, key: Private): Maybe<boolean>Functionality for private properties. This is an experimental feature, use at your own risk. Note: Private properties are not inherited. Do not rely on this, since it may change.
Upstream C++:
v8::Object::HasPrivate -
hasRealIndexedProperty(context: Context, index: number): Maybe<boolean>Binds upstream V8 C++
v8::Object::HasRealIndexedProperty. -
hasRealNamedCallbackProperty(context: Context, key: Name): Maybe<boolean>Binds upstream V8 C++
v8::Object::HasRealNamedCallbackProperty. -
hasRealNamedProperty(context: Context, key: Name): Maybe<boolean>Use HasRealNamedProperty() if you want to check if an object has an own property without causing side effects, i.e., without calling interceptors.
This function is similar to
Object.HasOwnProperty(), but it does not call interceptors.Note: Consider using non-masking interceptors, i.e., the interceptors are not called if the receiver has the real named property. See
PropertyHandlerFlags.kNonMasking.See also
Object.Has().Upstream C++:
v8::Object::HasRealNamedProperty -
internalFieldCount(): numberGets the number of internal fields for this Object.
Upstream C++:
v8::Object::InternalFieldCount -
isApiWrapper(): booleanReturns true if this object can be generally used to wrap object objects. This means that the object either follows the convention of using embedder fields to denote type/instance pointers or is using the Wrap()/Unwrap() APIs for the same purpose. Returns false otherwise.
Note that there may be other objects that use embedder fields but are not used as API wrapper objects. E.g.,
Promisemay in certain configuration use embedder fields but promises are not generally supported as API wrappers. The method will return false in those cases.Upstream C++:
v8::Object::IsApiWrapper -
isCallable(): booleanChecks whether a callback is set by the
ObjectTemplate.SetCallAsFunctionHandlermethod. When an Object is callable this method returns true.Upstream C++:
v8::Object::IsCallable -
isCodeLike(isolate: Isolate): booleanSupport for TC39 "dynamic code brand checks" proposal.
This API allows to query whether an object was constructed from a "code like" ObjectTemplate.
See also:
ObjectTemplate.SetCodeLikeUpstream C++:
v8::Object::IsCodeLike -
isConstructor(): booleanTrue if this object is a constructor.
Upstream C++:
v8::Object::IsConstructor -
isUndetectable(): booleanTrue if this object was created from an object template which was marked as undetectable. See
ObjectTemplate.MarkAsUndetectablefor more information.Upstream C++:
v8::Object::IsUndetectable -
objectProtoToString(context: Context): MaybeLocal<V8String>Call builtin Object.prototype.toString on this object. This is different from
Value.ToString()that may call user-defined toString function. This one does not.Upstream C++:
v8::Object::ObjectProtoToString -
set(context: Context, key: Value, value: Value): Maybe<boolean>Set only return Just(true) or Empty(), so if it should never fail, use result.Check().
Upstream C++:
v8::Object::Set -
set2(context: Context, key: Value, value: Value, receiver: MaybeLocal<V8Object>): Maybe<boolean>Set only return Just(true) or Empty(), so if it should never fail, use result.Check().
Upstream C++:
v8::Object::Set -
set3(context: Context, index: number, value: Value): Maybe<boolean>Set only return Just(true) or Empty(), so if it should never fail, use result.Check().
Upstream C++:
v8::Object::Set -
setAccessorProperty(name: Name, getter: V8Function, setter: V8Function, attributes: PropertyAttribute): voidSets an accessor property like
Template.SetAccessorProperty, but this method sets on this object directly.Upstream C++:
v8::Object::SetAccessorProperty -
setAlignedPointerInInternalField(index: number, value: number, tag: number): voidSets a 2-byte-aligned native pointer in an internal field. To retrieve such a field, GetAlignedPointerFromInternalField must be used, everything else leads to undefined behavior.
Upstream C++:
v8::Object::SetAlignedPointerInInternalField -
setIntegrityLevel(context: Context, level: IntegrityLevel): Maybe<boolean>Sets the integrity level of the object.
Upstream C++:
v8::Object::SetIntegrityLevel -
setInternalField(index: number, data: Data): voidSets the data in an internal field.
Upstream C++:
v8::Object::SetInternalField -
setPrivate(context: Context, key: Private, value: Value): Maybe<boolean>Binds upstream V8 C++
v8::Object::SetPrivate. -
setPrototype(context: Context, prototype: Value): Maybe<boolean>Set the prototype object (same as calling Object.setPrototypeOf(..)). This does not consult the security handler.
Upstream C++:
v8::Object::SetPrototype
V8Promise
class V8Promise extends V8Object
An instance of the built-in Promise constructor.
Upstream C++: v8::Promise (v8-promise.h)
Static Methods
-
static fromPtr(ptr: number): V8PromiseWraps a raw V8-wasm handle pointer as a
V8Promise.
Methods
-
catch(context: Context, handler: V8Function): MaybeLocal<V8Promise>Register a resolution/rejection handler with a promise. The handler is given the respective resolution/rejection value as an argument. If the promise is already resolved/rejected, the handler is invoked at the end of turn.
This performs the PerformPromiseThen abstract operation with a fresh native promise as result, rather than the similar Promise.prototype.then operation. In particular, it does not do species lookup on the Promise constructor, and is therefore guaranteed to return a Promise.
https://tc39.es/ecma262/#sec-performpromisethen
This is consistent with Promise reactions in WebIDL:
https://webidl.spec.whatwg.org/#dfn-perform-steps-once-promise-is-settled
Upstream C++:
v8::Promise::Catch -
hasHandler(): booleanReturns true if the promise has at least one derived promise, and therefore resolve/reject handlers (including default handler).
Upstream C++:
v8::Promise::HasHandler -
markAsHandled(): voidMarks this promise as handled to avoid reporting unhandled rejections.
Upstream C++:
v8::Promise::MarkAsHandled -
markAsSilent(): voidMarks this promise as silent to prevent pausing the debugger when the promise is rejected.
Upstream C++:
v8::Promise::MarkAsSilent -
result(): ValueReturns the content of the [[PromiseResult]] field. The Promise must not be pending.
Upstream C++:
v8::Promise::Result -
state(): PromisePromiseStateReturns the value of the [[PromiseState]] field.
Upstream C++:
v8::Promise::State -
then(context: Context, handler: V8Function): MaybeLocal<V8Promise>Binds upstream V8 C++
v8::Promise::Then. -
then2(context: Context, on_fulfilled: V8Function, on_rejected: V8Function): MaybeLocal<V8Promise>Binds upstream V8 C++
v8::Promise::Then.
V8Proxy
class V8Proxy extends V8Object
An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, 26.2.1).
Upstream C++: v8::Proxy (v8-proxy.h)
Static Methods
-
static fromPtr(ptr: number): V8ProxyWraps a raw V8-wasm handle pointer as a
V8Proxy. -
static new(context: Context, local_target: V8Object, local_handler: V8Object): MaybeLocal<V8Proxy>Creates a new Proxy for the target object.
Upstream C++:
v8::Proxy::New
Methods
-
getHandler(): ValueBinds upstream V8 C++
v8::Proxy::GetHandler. -
getTarget(): ValueBinds upstream V8 C++
v8::Proxy::GetTarget. -
isRevoked(): booleanBinds upstream V8 C++
v8::Proxy::IsRevoked. -
revoke(): voidBinds upstream V8 C++
v8::Proxy::Revoke.
V8Set
class V8Set extends V8Object
An instance of the built-in Set constructor (ECMA-262, 6th Edition, 23.2.1).
Upstream C++: v8::Set (v8-container.h)
Static Methods
-
static fromPtr(ptr: number): V8SetWraps a raw V8-wasm handle pointer as a
V8Set. -
static new(isolate: Isolate): V8SetCreates a new empty Set.
Upstream C++:
v8::Set::New
Methods
-
add(context: Context, key: Value): MaybeLocal<V8Set>Binds upstream V8 C++
v8::Set::Add. -
asArray(): V8ArrayReturns an array of the keys in this Set.
Upstream C++:
v8::Set::AsArray -
clear(): voidBinds upstream V8 C++
v8::Set::Clear. -
delete(context: Context, key: Value): Maybe<boolean>Binds upstream V8 C++
v8::Set::Delete. -
has(context: Context, key: Value): Maybe<boolean>Binds upstream V8 C++
v8::Set::Has. -
size(): numberBinds upstream V8 C++
v8::Set::Size.
V8SharedArrayBuffer
class V8SharedArrayBuffer extends V8Object
An instance of the built-in SharedArrayBuffer constructor.
Upstream C++: v8::SharedArrayBuffer (v8-array-buffer.h)
Static Methods
-
static fromPtr(ptr: number): V8SharedArrayBufferWraps a raw V8-wasm handle pointer as a
V8SharedArrayBuffer. -
static maybeNew(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode): MaybeLocal<V8SharedArrayBuffer>Create a new SharedArrayBuffer. Allocate
byte_lengthbytes, which are either zero-initialized or uninitialized. Allocated memory will be owned by a created SharedArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized. If allocation fails, the Maybe returned will be empty.Upstream C++:
v8::SharedArrayBuffer::MaybeNew -
static new(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode): V8SharedArrayBufferCreate a new SharedArrayBuffer. Allocate
byte_lengthbytes, which are either zero-initialized or uninitialized. Allocated memory will be owned by a created SharedArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized.Upstream C++:
v8::SharedArrayBuffer::New -
static new2(isolate: Isolate, backing_store: BackingStoreShared): V8SharedArrayBufferCreate a new SharedArrayBuffer with an existing backing store. The created array keeps a reference to the backing store until the array is garbage collected. Note that the IsExternal bit does not affect this reference from the array to the backing store.
In future IsExternal bit will be removed. Until then the bit is set as follows. If the backing store does not own the underlying buffer, then the array is created in externalized state. Otherwise, the array is created in internalized state. In the latter case the array can be transitioned to the externalized state using Externalize(backing_store).
Upstream C++:
v8::SharedArrayBuffer::New -
static newBackingStore(isolate: Isolate, byte_length: number, initialization_mode: BackingStoreInitializationMode, on_failure: BackingStoreOnFailureMode): BackingStoreReturns a new standalone BackingStore that is allocated using the array buffer allocator of the isolate. The allocation can either be zero initialized, or uninitialized. The result can be later passed to
SharedArrayBuffer.New.If the allocator returns
null, then the function may cause GCs in the given isolate and re-try the allocation.If on_failure is kOutOfMemory and GCs do not help, then the function will crash with an out-of-memory error.
Otherwise, if on_failure is kReturnNull and GCs do not help (or the byte_length is so large that the allocation cannot succeed), then a null result is returned.
Upstream C++:
v8::SharedArrayBuffer::NewBackingStore
Methods
-
byteLength(): numberData length in bytes.
Upstream C++:
v8::SharedArrayBuffer::ByteLength -
copyArrayBufferBytes(source_start: number, bytes_to_copy: number, target: V8SharedArrayBuffer, target_start: number): numberCopy up to
bytes_to_copybytes from this SharedArrayBuffer starting at positionsource_startto the target SharedArrayBuffer starting at positiontarget_start. Returns the number of bytes actually copied.Upstream C++:
v8::SharedArrayBuffer::CopyArrayBufferBytes -
data(): numberMore efficient shortcut for GetBackingStore()->Data(). The returned pointer is valid as long as the ArrayBuffer is alive.
Upstream C++:
v8::SharedArrayBuffer::Data -
getBackingStore(): BackingStoreSharedGet a shared pointer to the backing store of this array buffer. This pointer coordinates the lifetime management of the internal storage with any live ArrayBuffers on the heap, even across isolates. The embedder should not attempt to manage lifetime of the storage through other means.
Upstream C++:
v8::SharedArrayBuffer::GetBackingStore -
maxByteLength(): numberMaximum length in bytes.
Upstream C++:
v8::SharedArrayBuffer::MaxByteLength
V8Uint16Array
class V8Uint16Array extends TypedArray
An instance of Uint16Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Uint16Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Uint16ArrayWraps a raw V8-wasm handle pointer as a
V8Uint16Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Uint16ArrayBinds upstream V8 C++
v8::Uint16Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Uint16ArrayBinds upstream V8 C++
v8::Uint16Array::New.
V8Uint32Array
class V8Uint32Array extends TypedArray
An instance of Uint32Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Uint32Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Uint32ArrayWraps a raw V8-wasm handle pointer as a
V8Uint32Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Uint32ArrayBinds upstream V8 C++
v8::Uint32Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Uint32ArrayBinds upstream V8 C++
v8::Uint32Array::New.
V8Uint8Array
class V8Uint8Array extends TypedArray
An instance of Uint8Array constructor (ES6 draft 15.13.6).
Upstream C++: v8::Uint8Array (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Uint8ArrayWraps a raw V8-wasm handle pointer as a
V8Uint8Array. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Uint8ArrayBinds upstream V8 C++
v8::Uint8Array::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Uint8ArrayBinds upstream V8 C++
v8::Uint8Array::New.
V8Uint8ClampedArray
class V8Uint8ClampedArray extends TypedArray
An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
Upstream C++: v8::Uint8ClampedArray (v8-typed-array.h)
Static Methods
-
static fromPtr(ptr: number): V8Uint8ClampedArrayWraps a raw V8-wasm handle pointer as a
V8Uint8ClampedArray. -
static new(array_buffer: V8ArrayBuffer, byte_offset: number, length: number): V8Uint8ClampedArrayBinds upstream V8 C++
v8::Uint8ClampedArray::New. -
static new2(shared_array_buffer: V8SharedArrayBuffer, byte_offset: number, length: number): V8Uint8ClampedArrayBinds upstream V8 C++
v8::Uint8ClampedArray::New.
ValueDeserializer
class ValueDeserializer extends WasmHandle
Deserializes values from data written with ValueSerializer, or a compatible implementation.
Upstream C++: v8::ValueDeserializer (v8-value-serializer.h)
Methods
-
getWireFormatVersion(): numberReads the underlying wire format version. Likely mostly to be useful to legacy code reading old wire format versions. Must be called after ReadHeader.
Upstream C++:
v8::ValueDeserializer::GetWireFormatVersion -
readHeader(context: Context): Maybe<boolean>Reads and validates a header (including the format version). May, for example, reject an invalid or unsupported wire format.
Upstream C++:
v8::ValueDeserializer::ReadHeader -
readValue(context: Context): MaybeLocal<Value>Deserializes a JavaScript value from the buffer.
Upstream C++:
v8::ValueDeserializer::ReadValue -
setSupportsLegacyWireFormat(supports_legacy_wire_format: boolean): voidMust be called before ReadHeader to enable support for reading the legacy wire format (i.e., which predates this being shipped).
Don't use this unless you need to read data written by previous versions of
blink.ScriptValueSerializer.Upstream C++:
v8::ValueDeserializer::SetSupportsLegacyWireFormat -
transferArrayBuffer(transfer_id: number, array_buffer: V8ArrayBuffer): voidAccepts the array buffer corresponding to the one passed previously to
ValueSerializer.TransferArrayBuffer.Upstream C++:
v8::ValueDeserializer::TransferArrayBuffer -
transferSharedArrayBuffer(id: number, shared_array_buffer: V8SharedArrayBuffer): voidSimilar to TransferArrayBuffer, but for SharedArrayBuffer. The id is not necessarily in the same namespace as unshared ArrayBuffer objects.
Upstream C++:
v8::ValueDeserializer::TransferSharedArrayBuffer
ValueDeserializerDelegate
class ValueDeserializerDelegate extends WasmHandle
Upstream V8 C++ class v8::ValueDeserializer::Delegate (v8-value-serializer.h).
Methods
-
getSharedArrayBufferFromId(isolate: Isolate, clone_id: number): MaybeLocal<V8SharedArrayBuffer>Get a SharedArrayBuffer given a clone_id previously provided by
ValueSerializer.Delegate.GetSharedArrayBufferIdUpstream C++:
v8::ValueDeserializer::Delegate::GetSharedArrayBufferFromId -
getSharedValueConveyor(isolate: Isolate): SharedValueConveyor | nullGet the SharedValueConveyor previously provided by
ValueSerializer.Delegate.AdoptSharedValueConveyor.Upstream C++:
v8::ValueDeserializer::Delegate::GetSharedValueConveyor -
getWasmModuleFromId(isolate: Isolate, transfer_id: number): MaybeLocal<WasmModuleObject>Get a WasmModuleObject given a transfer_id previously provided by
ValueSerializer.Delegate.GetWasmModuleTransferIdUpstream C++:
v8::ValueDeserializer::Delegate::GetWasmModuleFromId -
readHostObject(isolate: Isolate): MaybeLocal<V8Object>The embedder overrides this method to read some kind of host object, if possible. If not, a suitable exception should be thrown and
Object | null() returned.Upstream C++:
v8::ValueDeserializer::Delegate::ReadHostObject
ValueSerializer
class ValueSerializer extends WasmHandle
Value serialization compatible with the HTML structured clone algorithm. The format is backward-compatible (i.e. safe to store to disk).
Upstream C++: v8::ValueSerializer (v8-value-serializer.h)
Methods
-
setTreatArrayBufferViewsAsHostObjects(mode: boolean): voidIndicate whether to treat ArrayBufferView objects as host objects, i.e. pass them to
Delegate.WriteHostObject. This should not be called when no Delegate was passed.The default is not to treat ArrayBufferViews as host objects.
Upstream C++:
v8::ValueSerializer::SetTreatArrayBufferViewsAsHostObjects -
transferArrayBuffer(transfer_id: number, array_buffer: V8ArrayBuffer): voidMarks an ArrayBuffer as havings its contents transferred out of band. Pass the corresponding ArrayBuffer in the deserializing context to
ValueDeserializer.TransferArrayBuffer.Upstream C++:
v8::ValueSerializer::TransferArrayBuffer -
writeDouble(value: number): voidBinds upstream V8 C++
v8::ValueSerializer::WriteDouble. -
writeHeader(): voidWrites out a header, which includes the format version.
Upstream C++:
v8::ValueSerializer::WriteHeader -
writeRawBytes(source: number, length: number): voidBinds upstream V8 C++
v8::ValueSerializer::WriteRawBytes. -
writeUint32(value: number): voidWrite raw data in various common formats to the buffer. Note that integer types are written in base-128 varint format, not with a binary copy. For use during an override of
Delegate.WriteHostObject.Upstream C++:
v8::ValueSerializer::WriteUint32 -
writeUint64(value: bigint): voidBinds upstream V8 C++
v8::ValueSerializer::WriteUint64. -
writeValue(context: Context, value: Value): Maybe<boolean>Serializes a JavaScript value into the buffer.
Upstream C++:
v8::ValueSerializer::WriteValue
ValueSerializerDelegate
class ValueSerializerDelegate extends WasmHandle
Upstream V8 C++ class v8::ValueSerializer::Delegate (v8-value-serializer.h).
Methods
-
freeBufferMemory(buffer: number): voidFrees a buffer allocated with
ReallocateBufferMemory.The default implementation uses the stdlib's
free()function.Upstream C++:
v8::ValueSerializer::Delegate::FreeBufferMemory -
getSharedArrayBufferId(isolate: Isolate, shared_array_buffer: V8SharedArrayBuffer): Maybe<number>Called when the ValueSerializer is going to serialize a SharedArrayBuffer object. The embedder must return an ID for the object, using the same ID if this SharedArrayBuffer has already been serialized in this buffer. When deserializing, this ID will be passed to
ValueDeserializer.GetSharedArrayBufferFromIdasclone_id.If the object cannot be serialized, an exception should be thrown and
Nothing<uint32_t>() returned.Upstream C++:
v8::ValueSerializer::Delegate::GetSharedArrayBufferId -
getWasmModuleTransferId(isolate: Isolate, module_: WasmModuleObject): Maybe<number>Binds upstream V8 C++
v8::ValueSerializer::Delegate::GetWasmModuleTransferId. -
hasCustomHostObject(isolate: Isolate): booleanThe embedder overrides this method to enable custom host object filter with
Delegate.IsHostObject.This method is called at most once per serializer.
Upstream C++:
v8::ValueSerializer::Delegate::HasCustomHostObject -
isHostObject(isolate: Isolate, object: V8Object): Maybe<boolean>The embedder overrides this method to determine if an JS object is a host object and needs to be serialized by the host.
Upstream C++:
v8::ValueSerializer::Delegate::IsHostObject -
throwDataCloneError(message: V8String): voidHandles the case where a DataCloneError would be thrown in the structured clone spec. Other V8 embedders may throw some other appropriate exception type.
Upstream C++:
v8::ValueSerializer::Delegate::ThrowDataCloneError -
writeHostObject(isolate: Isolate, object: V8Object): Maybe<boolean>The embedder overrides this method to write some kind of host object, if possible. If not, a suitable exception should be thrown and
Nothing<bool>() returned.Upstream C++:
v8::ValueSerializer::Delegate::WriteHostObject