polyvalid 0.1.7

A validator for package names, namespace, username and app name on wasmer
Documentation
---
source: /Users/xorcist/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-pack-testing-0.7.0/src/autodiscover.rs
---
const fs = require("fs/promises");
const { Polyvalid: _Polyvalid } = require("./polyvalid/polyvalid.js");

class Bindings {
    constructor() {
        this._cache = {}
    }

    /** Lazily fetch and compile the WebAssembly module */
    async _getModule(filename) {
        if (filename in this._cache) {
            return this._cache[filename];
        }

        const wasm = await fs.readFile(`${__dirname}/${filename}`);
        this._cache[filename] = await WebAssembly.compile(wasm);
        return this._cache[filename];
    }
    async polyvalid(options) {
        const wrapper = new _Polyvalid();
        const module = await this._getModule("polyvalid/polyvalid.wasm");
        const imports = options?.imports || {};

        await wrapper.instantiate(module, imports);

        return wrapper;
    }
}

module.exports = { Bindings };