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

wasm-json-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wasm-json-toolkit

this convertes wasm binaries to json and json to wasm binaries

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-71.87%
Maintainers
1
Weekly downloads
 
Created
Source

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

A small toolkit for converting wasm binaries into json and back.

INSTALL

npm install wasm-json-toolkit

USAGE

const fs = require('fs')
const wasm2json = require('wasm-json-toolkit').wasm2json

const wasm = fs.readFileSync('./test.wasm')
const json = wasm2json(wasm)

console.log(JSON.stringify(json, null, 2))

exammple json output

wast

(module
  (func $addTwo (param i32 i32) (result i32)
    (i32.add
      (get_local 0)
      (get_local 1)))
  (export "addTwo" (func $addTwo)))

wasm

0x010661646454776f00000a09010700200020016a0b

json

[
  {
    "magic": [0,97,115,109],
    "version": [13,0,0,0]
  },
  {
    "section": "type",
    "entries": [
      {
        "form": "func",
        "params": ["i32", "i32"],
        "return_type": "i32"
      }
    ]
  },
  {
    "section": "function",
    "entries": [0]
  },
  {
    "section": "export",
    "entries": [
      {
        "field_str": "addTwo",
        "kind": "Function",
        "index": 0
      }
    ]
  },
  {
    "section": "code",
    "entries": [
      {
        "locals": [],
        "code": [
          {
            "name": "get_local",
            "immediaties": "0"
          },
          {
            "name": "get_local",
            "immediaties": "1"
          },
          {
            "name": "i32.add"
          },
          {
            "name": "end"
          }
        ]
      }
    ]
  }
]

API

wasm2json

converts a wasm binary into a json representation

Parameters

  • Buffer

Returns Object

json2wasm

converts a json representation to a wasm binary

Parameters

  • Object

Returns Buffer

LICENSE

MPL-2.0

Keywords

FAQs

Package last updated on 06 Dec 2016

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