
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Compile WebAssembly .wasm files to a TypeScript module.
wasm2ts -i example.wasm -o example.ts
npm install wasm2ts -g
Wat Code:
;; example.wasm
(module
(type (;0;) (func (param i32) (result i32)))
(type (;1;) (func))
(func (;0;) (type 0) (param i32) (result i32)
;; Some wat code
end)
(func (;1;) (type 0) (param i32) (result i32)
;; Some wat code
end)
(func (;2;) (type 1))
(table (;0;) 0 0 funcref)
(memory (;0;) 1)
(export "wasm.memory" (memory 0))
(export "fib" (func 0))
(export "fib2" (func 1))
(export "_start" (func 2))
(elem (;0;) (i32.const 0) func))
$ wasm2ts -i fib.wasm
Output file: D:\path\to\ts\fib.ts
File size: 1062 bytes
Generated TypeScript Code:
// Base64 2 Uint8Array
const Base2Uint8 = (base64: string) => {
const binstr = atob(base64);
const len = binstr.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binstr.charCodeAt(i);
}
return bytes;
};
type ExportType = { fib: Function; fib2: Function; _start: Function; };
export default async (importObject: WebAssembly.Imports): Promise<ExportType> => {
let wasmstr = "AGFzbQEA...Some Base64 Code...IAAAAs=";
const wasm = Base2Uint8(wasmstr);
const wasmModule = new WebAssembly.Module(wasm);
const wasmInstance = new WebAssembly.Instance(wasmModule, importObject);
const wasmExports = wasmInstance.exports as ExportType;
return wasmExports;
};
wasm2ts
will compress the wasm file using Gzip if this will make the file smaller.
MIT
FAQs
Compile WebAssembly .wasm files to a TypeScript module.
The npm package wasm2ts receives a total of 0 weekly downloads. As such, wasm2ts popularity was classified as not popular.
We found that wasm2ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.