wasm-rquickjs-cli 0.5.3

Tool for wrapping JavaScript modules as WebAssembly components using the QuickJS engine
import * as iface from 'quickjs:example3/iface';

export const test = async (input) => {
    let hello = new iface.Hello(input);
    let world = new iface.Hello('World');

    let comparison1 = iface.Hello.compare(hello, world);
    let comparison2 = iface.Hello.compare(world, hello);

    console.log(`Comparison 1: ${comparison1}`);
    console.log(`Comparison 2: ${comparison2}`);

    const dump1 = await iface.dump(hello);
    console.log(`Dump 1: ${dump1}`);
    const dump2 = await iface.dump(undefined);
    console.log(`Dump 2: ${dump2}`);

    using merged = iface.Hello.merge(hello, world);

    const dump3 = await iface.dumpAll([merged]);
    console.log(`Dump 3: ${dump3}`);

    const result = await merged.getName();

    return result;
};


export const testStaticCreate = (input) => {
    for (const name of ['create', 'compare', 'merge']) {
        const descriptor = Object.getOwnPropertyDescriptor(iface.HelloWithStaticCreate, name);
        if (!descriptor || descriptor.enumerable || typeof descriptor.value !== 'function') {
            throw new Error(`Unexpected static method descriptor for ${name}`);
        }
    }
    // NOTE: we cannot implement the constructor in js properly,
    //       so we just check for the existence of functions
    console.log(iface.HelloWithStaticCreate);
    console.log(iface.HelloWithStaticCreate.create);
    console.log(iface.HelloWithStaticCreate.compare);
    console.log(iface.HelloWithStaticCreate.merge);

    return input;
};