npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wuyuchentr/webassembly-runtime-embed

v5.0.0

Published

Embed WebAssembly runtime in Node.js with WASI support, multi-instance isolation, resource limits, and remote loading with cache.

Readme

@wuyuchentr/webassembly-runtime-embed

Embed WebAssembly runtime in Node.js with WASI support, multi-instance isolation, resource limits, and remote loading with cache. A pure Node.js alternative to wasmtime/wasmer for embedded scenarios.

Install

npm install @wuyuchentr/webassembly-runtime-embed

Quick start

const { createRuntime } = require('@wuyuchentr/webassembly-runtime-embed');

async function main() {
  const runtime = createRuntime();

  const inst = await runtime.load('./add.wasm');
  const result = inst.call('add', 1, 2);
  console.log(result); // 3
}

CLI

webassembly-runtime-embed run add.wasm --export add --args 1 2
webassembly-runtime-embed info module.wasm
webassembly-runtime-embed cache clear

WASI support (v2)

Full wasi_snapshot_preview1 implementation with filesystem sandboxing.

const runtime = createRuntime();

runtime.registerWASI({
  args: ['myapp.wasm', '--verbose'],
  env: { HOME: '/data', DEBUG: '1' },
  preopens: [
    { virtual: '/sandbox', real: '/path/to/host/dir' },
  ],
});

const inst = await runtime.load('./myapp.wasm');
// WASM can now use stdin/stdout/stderr, file I/O, clock, random, etc.

Supported WASI functions

| Category | Functions | |----------|-----------| | Args | args_sizes_get, args_get | | Environ | environ_sizes_get, environ_get | | Clock | clock_time_get, clock_res_get | | Random | random_get | | Stdio | fd_read (stdin), fd_write (stdout/stderr) | | File I/O | fd_read, fd_write, fd_close, fd_seek, fd_tell, fd_fdstat_get, fd_fdstat_set_flags, fd_filestat_get, fd_readdir, fd_datasync, fd_sync, fd_advise, fd_allocate, fd_renumber | | Filesystem | path_open, path_create_directory, path_remove_directory, path_unlink_file, path_rename, path_filestat_get, path_readlink, path_symlink | | Preopens | fd_prestat_get, fd_prestat_dir_name | | Process | proc_exit | | Poll | poll_oneoff, sched_yield |

Filesystem sandboxing

All WASM file operations are sandboxed within preopened directories. Paths like /sandbox/file.txt are transparently mapped to real host paths. Path traversal outside the preopened root is rejected.

Features

Function calling with type conversion

inst.call('add', 1, 2);             // i32 → i32
inst.call('multiply', 2.5, 3.0);    // f64 → f64

Memory access

const mem = inst.getMemory();
mem.writeCString(0, 'hello world');
const str = mem.readCString(0);
mem.writeF64(1024, 3.14159);

Host function registration

runtime.registerFunction('env', 'js_log', (ptr, len) => {
  const str = inst.getMemory().readString(ptr, len);
  console.log('[wasm]', str);
});

Resource limits

const inst = await runtime.load('./module.wasm', {
  maxMemory: 65536 * 4,
  timeout: 1000,
});

Remote loading with cache

const inst = await runtime.loadRemote('https://example.com/module.wasm', {
  ttl: 3600,
});

API

createRuntime(options)

runtime.load(source, options)

| Option | Default | Description | |--------|---------|-------------| | maxMemory | 0 | Maximum memory in bytes | | timeout | 0 | Execution timeout in ms | | argTypes | [] | Argument types for auto-conversion | | returnType | null | Return type for auto-conversion |

runtime.registerWASI(options)

| Option | Default | Description | |--------|---------|-------------| | args | [] | Command-line arguments | | env | {} | Environment variables | | preopens | [] | Array of { virtual, real } path mappings |

runtime.registerFunction(module, name, fn)

inst.call(name, ...args)

inst.getMemory()

MemoryView methods

  • readU8/16/32(offset), readI32(offset), readF32/64(offset)
  • readString(offset, length), readCString(offset)
  • writeU8/16/32(offset, value), writeI32(offset, value)
  • writeF32/64(offset, value), writeString(offset, str), writeCString(offset, str)
  • alloc(size), allocString(str), free()

License

MIT