Licence
MIT
Version
3.0.2
Deps
0
Size
27 kB
Vulns
0
Weekly
0
Detect WebAssembly Features
A tiny, zero-dependency library for detecting WebAssembly features (~2 kB minified).
Support features
- Reference types (standardized)
- BigInt between js and wasm (standardized)
- Bulk memory operations (standardized)
- Exceptions (--experimental-wasm-eh)
- Memory 64-bit (--experimental-wasm-memory64)
- Custom page sizes
- Mutable globals (standardized)
- Multi values (standardized)
- Saturated (non-trapping) conversions from float to int (standardized)
- Sign extensions (standardized)
- Tail calls (--experimental-wasm-return-call)
- Threads (standardized)
- SIMD (standardized)
- Relaxed SIMD
- GC
- Type reflection (--experimental-wasm-type-reflection)
- Typed function references
- JS String builtins
Install
yarn add wasm-check
or
npm i wasm-check
Usage
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.0
Check 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?