Library for detect WebAssembly post-MVP features in NodeJS & Browser. Small and with zero dependencies.
About post-MVP WebAssembly features
https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#tracking-issues
Tests on Canary with flags:
Enable some experimental features for Chrome Canary (Mac):
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --js-flags="--experimental-wasm-eh"
Support feature detections
- [x] Reference types (standardized)
- [x] BigInt between js and wasm (standardized)
- [x] Bulk memory operations (standardized)
- [x] Memory 64-bit (--experimental-wasm-memory64)
- [x] Exceptions (--experimental-wasm-eh)
- [x] Multi values (standardized)
- [x] Tail recursion calls (--experimental-wasm-return-call)
- [x] Saturated (non-trapping) conversions from float to int (standardized)
- [x] Sign extensions (standardized)
- [x] SIMD (standardized)
- [x] Threads (standardized)
- [x] Type reflection (--experimental-wasm-type-reflection)
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 (MVP)
console.log(check.support(1)); // ^^^
console.log(check.support(2)); // WebAssembly 2.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: false,
memory64: false,
mutableGlobal: true,
multiValue: true,
saturateConversions: true,
signExtensions: true,
tailCall: false,
threads: false,
simd: false,
references: false,
typeReflection: false,
funcReferences: false
}
Or check concrete feature
import * as check from 'wasm-check';
console.log(check.feature.simd); // has SIMD support?
console.log(check.feature.tailCalls); // has tail call optimization support?
TODO
- [ ] GC integration feature check