
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
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 1 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.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.