V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
v8::Module Class Reference

#include <v8.h>

Public Types

enum  Status {
  kUninstantiated, kInstantiating, kInstantiated, kEvaluating,
  kEvaluated, kErrored
}
 
typedef MaybeLocal< Module >(* ResolveCallback) (Local< Context > context, Local< String > specifier, Local< Module > referrer)
 

Public Member Functions

Status GetStatus () const
 
Local< ValueGetException () const
 
int GetModuleRequestsLength () const
 
Local< StringGetModuleRequest (int i) const
 
Location GetModuleRequestLocation (int i) const
 
int GetIdentityHash () const
 
V8_WARN_UNUSED_RESULT Maybe< boolInstantiateModule (Local< Context > context, ResolveCallback callback)
 
V8_WARN_UNUSED_RESULT MaybeLocal< ValueEvaluate (Local< Context > context)
 
Local< ValueGetModuleNamespace ()
 
Local< UnboundModuleScriptGetUnboundModuleScript ()
 

Detailed Description

A compiled JavaScript module.

Definition at line 1131 of file v8.h.

Member Enumeration Documentation

◆ Status

The different states a module can be in.

This corresponds to the states used in ECMAScript except that "evaluated" is split into kEvaluated and kErrored, indicating success and failure, respectively.

Definition at line 1140 of file v8.h.

Member Function Documentation

◆ Evaluate()

MaybeLocal< Value > v8::Module::Evaluate ( Local< Context >  context)

Evaluates the module and its dependencies.

If status is kInstantiated, run the module's code. On success, set status to kEvaluated and return the completion value; on failure, set status to kErrored and propagate the thrown exception (which is then also available via |GetException|).

Definition at line 2281 of file api.cc.

◆ GetException()

Local< Value > v8::Module::GetException ( ) const

For a module in kErrored status, this returns the corresponding exception.

Definition at line 2211 of file api.cc.

◆ GetIdentityHash()

int v8::Module::GetIdentityHash ( ) const

Returns the identity hash for this object.

Definition at line 2268 of file api.cc.

◆ GetModuleNamespace()

Local< Value > v8::Module::GetModuleNamespace ( )

Returns the namespace object of this module.

The module's status must be at least kInstantiated.

Definition at line 2249 of file api.cc.

◆ GetModuleRequest()

Local< String > v8::Module::GetModuleRequest ( int  i) const

Returns the ith module specifier in this module. i must be < GetModuleRequestsLength() and >= 0.

Definition at line 2224 of file api.cc.

◆ GetModuleRequestLocation()

Location v8::Module::GetModuleRequestLocation ( int  i) const

Returns the source location (line number and column number) of the ith module specifier's first occurrence in this module.

Definition at line 2234 of file api.cc.

◆ GetModuleRequestsLength()

int v8::Module::GetModuleRequestsLength ( ) const

Returns the number of modules requested by this module.

Definition at line 2219 of file api.cc.

◆ GetStatus()

Module::Status v8::Module::GetStatus ( ) const

Returns the module's current status.

Definition at line 2191 of file api.cc.

◆ GetUnboundModuleScript()

Local< UnboundModuleScript > v8::Module::GetUnboundModuleScript ( )

Returns the corresponding context-unbound module script.

The module must be unevaluated, i.e. its status must not be kEvaluating, kEvaluated or kErrored.

Definition at line 2259 of file api.cc.

◆ InstantiateModule()

Maybe< bool > v8::Module::InstantiateModule ( Local< Context >  context,
Module::ResolveCallback  callback 
)

Instantiates the module and its dependencies.

Returns an empty Maybe<bool> if an exception occurred during instantiation. (In the case where the callback throws an exception, that exception is propagated.)

Definition at line 2270 of file api.cc.


The documentation for this class was generated from the following files: