Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wasmer/wasi

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wasmer/wasi

Isomorphic Javascript library for interacting with WASI Modules in Node.js and the Browser. 📚

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-54.38%
Maintainers
2
Weekly downloads
 
Created
Source

@wasmer/wasi

Isomorphic Javascript library for interacting with WASI Modules in Node.js and the Browser. 📚

Documentation for Wasmer-JS Stack can be found on the Wasmer Docs.

Table of Contents

Features

This project is forked from node-wasi, a Node implementation made by Gus Caplan. 🙏😄 It uses the same API than the future WASI integration in Node, to help transition to it once it becomes available in Node.

However, @wasmer/wasi is focused on:

  • Bringing WASI to an Isomorphic context (Node.js and the Browser) 🖥️
  • Make it easy to plug in different filesystems (via wasmfs) 📂
  • Make it type-safe using Typescript 👷
  • Pure JavaScript implementation (no Native bindings needed) 🚀
  • ~ 15KB minified + gzipped 📦

Installation

For instaling @wasmer/wasi, just run this command in your shell:

npm install --save @wasmer/wasi

Quick Start

This quick start is for browsers. For node, WasmFs is not required

import { WASI } from "@wasmer/wasi";
import { WasmFs } from "@wasmer/wasmfs";

// Instantiate a new WASI Instance
const wasmFs = new WasmFs();
let wasi = new WASI({
  args: [],
  env: {},
  bindings: {
    ...WASI.defaultBindings,
    fs: wasmFs.fs
  }
});

const startWasiTask = async () => {
  // Fetch our Wasm File
  const response = await fetch("./my-wasi-module.wasm");
  const responseArrayBuffer = await response.arrayBuffer();

  // Instantiate the WebAssembly file
  const wasm_bytes = new Uint8Array(responseArrayBuffer).buffer;
  let { instance } = await WebAssembly.instantiate(wasm_bytes, {
    wasi_unstable: wasi.wasiImport
  });

  // Start the WebAssembly WASI instance!
  wasi.start(instance);

  // Output what's inside of /dev/stdout!
  const stdout = await wasmFs.getStdOut();
  console.log(stdout);
};
startWasiTask();

Reference API

The Reference API Documentation can be found on the @wasmer/wasi Reference API Wasmer Docs.

Contributing

This project follows the all-contributors specification.

Contributions of any kind are welcome! 👍

Keywords

FAQs

Package last updated on 21 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc