https://github.com/maxgraey/wasm-check
TypeScript / JavaScript library for detect WebAssembly features in node.js & browser
https://github.com/maxgraey/wasm-check
check detect detection feature support validate wasm webassembly
Last synced: 9 months ago
JSON representation
TypeScript / JavaScript library for detect WebAssembly features in node.js & browser
- Host: GitHub
- URL: https://github.com/maxgraey/wasm-check
- Owner: MaxGraey
- License: mit
- Created: 2019-04-01T16:13:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-20T04:25:23.000Z (over 3 years ago)
- Last Synced: 2025-05-08T00:39:20.979Z (9 months ago)
- Topics: check, detect, detection, feature, support, validate, wasm, webassembly
- Language: TypeScript
- Homepage:
- Size: 162 KB
- Stars: 41
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/wasm-check)[](LICENSE.md)
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](https://github.com/WebAssembly/reference-types) _(standardized)_
- [x] [BigInt between js and wasm](https://github.com/WebAssembly/JS-BigInt-integration) _(standardized)_
- [x] [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) _(standardized)_
- [x] [Memory 64-bit](https://github.com/WebAssembly/memory64) _(--experimental-wasm-memory64)_
- [x] [Exceptions](https://github.com/WebAssembly/exception-handling) _(--experimental-wasm-eh)_
- [x] [Multi values](https://github.com/WebAssembly/multi-value) _(standardized)_
- [x] [Tail recursion calls](https://github.com/webassembly/tail-call) _(--experimental-wasm-return-call)_
- [x] [Saturated (non-trapping) conversions from float to int](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) _(standardized)_
- [x] [Sign extensions](https://github.com/WebAssembly/sign-extension-ops) _(standardized)_
- [x] [SIMD](https://github.com/webassembly/simd) _(standardized)_
- [x] [Threads](https://github.com/webassembly/threads) _(standardized)_
- [x] [Type reflection](https://github.com/WebAssembly/js-types) _(--experimental-wasm-type-reflection)_
## Install
```
yarn add wasm-check
```
or
```
npm i wasm-check
```
## Usage
#### Check supported WebAssembly version
```ts
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
```ts
import * as check from 'wasm-check';
console.log(check.supportStreaming);
```
#### Get all post-MVP WebAssembly features
```ts
import * as check from 'wasm-check';
const features = { ...check.feature };
console.log(features);
```
Output:
```js
{
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
```ts
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