1- "use strict" ;
2-
31// Runtime header offsets
42const ID_OFFSET = - 8 ;
53const SIZE_OFFSET = - 4 ;
@@ -297,7 +295,7 @@ function isModule(src) {
297295}
298296
299297/** Asynchronously instantiates an AssemblyScript module from anything that can be instantiated. */
300- async function instantiate ( source , imports = { } ) {
298+ export async function instantiate ( source , imports = { } ) {
301299 if ( isResponse ( source = await source ) ) return instantiateStreaming ( source , imports ) ;
302300 const module = isModule ( source ) ? source : await WebAssembly . compile ( source ) ;
303301 const extended = preInstantiate ( imports ) ;
@@ -306,21 +304,17 @@ async function instantiate(source, imports = {}) {
306304 return { module, instance, exports } ;
307305}
308306
309- exports . instantiate = instantiate ;
310-
311307/** Synchronously instantiates an AssemblyScript module from a WebAssembly.Module or binary buffer. */
312- function instantiateSync ( source , imports = { } ) {
308+ export function instantiateSync ( source , imports = { } ) {
313309 const module = isModule ( source ) ? source : new WebAssembly . Module ( source ) ;
314310 const extended = preInstantiate ( imports ) ;
315311 const instance = new WebAssembly . Instance ( module , imports ) ;
316312 const exports = postInstantiate ( extended , instance ) ;
317313 return { module, instance, exports } ;
318314}
319315
320- exports . instantiateSync = instantiateSync ;
321-
322316/** Asynchronously instantiates an AssemblyScript module from a response, i.e. as obtained by `fetch`. */
323- async function instantiateStreaming ( source , imports = { } ) {
317+ export async function instantiateStreaming ( source , imports = { } ) {
324318 if ( ! WebAssembly . instantiateStreaming ) {
325319 return instantiate (
326320 isResponse ( source = await source )
@@ -335,10 +329,8 @@ async function instantiateStreaming(source, imports = {}) {
335329 return { ...result , exports } ;
336330}
337331
338- exports . instantiateStreaming = instantiateStreaming ;
339-
340332/** Demangles an AssemblyScript module's exports to a friendly object structure. */
341- function demangle ( exports , extendedExports = { } ) {
333+ export function demangle ( exports , extendedExports = { } ) {
342334 extendedExports = Object . create ( extendedExports ) ;
343335 const setArgumentsLength = exports [ "__argumentsLength" ]
344336 ? length => { exports [ "__argumentsLength" ] . value = length ; }
@@ -420,4 +412,9 @@ function demangle(exports, extendedExports = {}) {
420412 return extendedExports ;
421413}
422414
423- exports . demangle = demangle ;
415+ export default {
416+ instantiate,
417+ instantiateSync,
418+ instantiateStreaming,
419+ demangle
420+ } ;
0 commit comments