npm.io
3.0.2 • Published 5 months ago

wasm-check

Licence
MIT
Version
3.0.2
Deps
0
Size
27 kB
Vulns
0
Weekly
0

NPM registryNPM license

Detect WebAssembly Features

A tiny, zero-dependency library for detecting WebAssembly features (~2 kB minified).

Support features

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?

Keywords