JSPM

  • Created
  • Published
  • Downloads 11623
  • Score
    100M100P100Q131011F
  • License MIT

TypeScript / JavaScript library for detect WebAssembly features in node.js & browser

Package Exports

  • wasm-check

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wasm-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM registryNPM license

TypeScript / JavaScript library for detect WebAssembly post-MVP features in node.js & browser

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"

More experimental js-flags for v8:

--experimental-wasm-anyref
--experimental-wasm-bulk-memory
--experimental-wasm-eh
--experimental-wasm-mv
--experimental-wasm-return-call
--experimental-wasm-sat-f2i-conversions
--experimental-wasm-se
--experimental-wasm-simd
--experimental-wasm-threads

Install

yarn add wasm-check

or

npm i wasm-check

Usage

Check supported WebAssembly version

import check from 'wasm-check';
// or for node.js (without babel or typescript):
// const check = require('wasm-check').default;

console.log(check.support()); // default MVP
console.log(check.support(1)); // same
console.log(check.support(2)); // version 2 (for future)

Check supporting streaming compilation

import check from 'wasm-check';

console.log(check.supportStreaming);

Get all post-MVP WebAssembly features

import check from 'wasm-check';

const features = { ...check.feature };
console.log(features);

Output:

{ bigInt: false,
  bulk: false,
  exceptions: false,
  mutableGlobals: true,
  multiValues: false,
  saturateConversions: false,
  signExtensions: true,
  tailCalls: false,
  threads: false,
  simd: false,
  references: false,
  functionReferences: false }

Or check concrete feature

import 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
  • Web IDL Bindings (host binding) feature check (?)