wasm-check
v3.0.2
Published
TypeScript / JavaScript library for detect WebAssembly features in node.js & browser
Downloads
226,823
Maintainers
Readme
Detect WebAssembly Features
A tiny, zero-dependency library for detecting WebAssembly features (~2 kB minified).
Support features
- [x] Reference types (standardized)
- [x] BigInt between js and wasm (standardized)
- [x] Bulk memory operations (standardized)
- [x] Exceptions (--experimental-wasm-eh)
- [x] Memory 64-bit (--experimental-wasm-memory64)
- [x] Custom page sizes
- [x] Mutable globals (standardized)
- [x] Multi values (standardized)
- [x] Saturated (non-trapping) conversions from float to int (standardized)
- [x] Sign extensions (standardized)
- [x] Tail calls (--experimental-wasm-return-call)
- [x] Threads (standardized)
- [x] SIMD (standardized)
- [x] Relaxed SIMD
- [x] GC
- [x] Type reflection (--experimental-wasm-type-reflection)
- [x] Typed function references
- [x] JS String builtins
Install
yarn add wasm-checkor
npm i wasm-checkUsage
Check supported WebAssembly version
import * as check from 'wasm-check';
// or
// const check = require('wasm-check');
console.log(check.support()); // WebAssembly >= 1.0
console.log(check.support(1)); // ^^^
console.log(check.support(2)); // WebAssembly >= 2.0
console.log(check.support(3)); // WebAssembly >= 3.0Check supporting streaming compilation
import * as check from 'wasm-check';
console.log(check.supportStreaming);Get all post-MVP WebAssembly features
import * as check from 'wasm-check';
const features = { ...check.feature };
console.log(features);Output:
{
bigInt: true,
bulk: true,
exceptions: true,
memory64: true,
customPageSizes: false,
mutableGlobal: true,
multiValue: true,
saturateConversions: true,
signExtensions: true,
tailCall: true,
threads: true,
simd: true,
relaxedSimd: true,
gc: true,
references: true,
typeReflection: false,
funcReferences: true,
jsStringBuiltins: true
}Or check concrete feature
import * as check from 'wasm-check';
console.log(check.feature.simd); // has SIMD support?
console.log(check.feature.relaxedSimd); // has Relaxed SIMD support?
console.log(check.feature.tailCall); // has tail call support?
console.log(check.feature.gc); // has Wasm GC support?
console.log(check.feature.jsStringBuiltins); // has JS String builtins support?