New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-inline-wasm

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-inline-wasm

A tool for bundling a WebAssembly .wasm file into a .js library file with async loading.

latest
Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
125
-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

js-inline-wasm

A tool for bundling a WebAssembly .wasm file into a .js ES6 library file with async loading.

Installation

npm install -D js-inline-wasm

Usage

$ inlinewasm sample.wasm [--output sample.js] [--type fetch]

In package.json

scripts: {
    "inlinewasm": "inlinewasm wasm/sample.wasm --output build/sample.js"
}

Options

  • --input file The .wasm file to inline

  • -o, --output file The .js file to create

  • -t, --type typeName The type of JavaScript file to generate

  • -h, --help Show this Help page

Types

Each type outputs a different variant of JavaScript file

-type fetch

Creates a JavaScript file with a default export function that can be used anywhere you could use fetch(). e.g.

import fetchSample from 'sample'; // sample.js contains the bundled .wasm

WebAssembly.instantiateStreaming(fetchSample)
    .then(obj => obj.instance.exports.exported_func());

-type decoded

Creates a JavaScript file with a default export byte array containing the decoded .wasm content

Note: You'll probably want to use WebAssembly.instantiateStreaming() in most cases, as it is more efficient than instantiate().

import decodedSample from 'sample'; // sample.js contains the bundled .wasm

WebAssembly.instantiate(decodedSample)
    .then(obj => obj.instance.exports.exported_func());

-type encoded

Creates a JavaScript file with a default export string value containing the base64 encoded .wasm file

import encodedSample from 'sample'; // sample.js contains the bundled .wasm

// Decode the base64 string then compile...

Keywords

webassembly

FAQs

Package last updated on 05 Jun 2019

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