An AbstractModuleSource object represents the compiled source of a module obtained with import source or import.source(). There is no directly visible AbstractModuleSource constructor.
Description
The AbstractModuleSource constructor (often referred to as %AbstractModuleSource% to indicate its "intrinsicness", since it does not correspond to any global exposed to a JavaScript program) serves as the superclass of all module source subclasses, providing a common interface of utility methods. This constructor is not directly exposed: there is no global AbstractModuleSource property. It is only accessible through Object.getPrototypeOf(moduleSourceObject.constructor) and similar.
AbstractModuleSource objects
JavaScript module source objects will be added by the ECMAScript Module Phase Imports proposal.
Constructor
This object cannot be instantiated directly — attempting to construct it with new throws a TypeError.
import source modSource from "./module.wasm";
new (Object.getPrototypeOf(modSource.constructor))();
// TypeError: Abstract class AbstractModuleSource not directly constructable
Instead, obtain a module source object using import source, import.source(), or a concrete module type's API, such as WebAssembly.Module(). These mechanisms do not call the abstract constructor.
Instance properties
These properties are defined on AbstractModuleSource.prototype and shared by all AbstractModuleSource subclass instances.
- Object/constructor
- : The constructor function that created the instance object.
AbstractModuleSource.prototype.constructoris the hiddenAbstractModuleSourceconstructor function, but each module source subclass also defines its ownconstructorproperty.
- : The constructor function that created the instance object.
AbstractModuleSource.prototype[Symbol.toStringTag]- : The initial value of the
AbstractModuleSource.prototype[Symbol.toStringTag]property is a getter that returns a string based on the constructor's identity, such as"WebAssembly.Module"or"ModuleSource". It returnsundefinedif thethisvalue is not an instance of one of the module source subclasses. This property is used in Object.prototype.toString().
- : The initial value of the
Specifications
Browser compatibility
See also
WebAssembly.Module- Operators/import/source
- Statements/import/source
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
