Need help with wasm-feature-detect?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

GoogleChromeLabs
303 Stars 24 Forks Apache License 2.0 116 Commits 5 Opened issues

Description

A small library to detect which features of WebAssembly are supported.

Services available

!
?

Need anything else?

Contributors list

WebAssembly Feature Detection

A small library to detect which features of WebAssembly are supported.

  • ✅ Runs in all major browsers
  • ✅ Runs in Node
  • ✅ Provided as an ES6 module, CommonJS and UMD module.
  • ✅ CSP compatible
  • ✅ Only ~560B gzipped

Installation

npm install -g wasm-feature-detect

Usage

If required, there’s also a UMD version


Detectors

All detectors return a

Promise
.

| Function | Proposal | | ----------------------- | ------------------------------------------------------------------------------------------------------------ | |

bigInt()
| BigInt integration | |
bulkMemory()
| Bulk memory operations | |
exceptions()
| Exception handling | |
memory64()
| Memory64 | |
multiValue()
| Multi-value | |
mutableGlobals()
| Importable/Exportable mutable globals | |
referenceTypes()
| Reference Types | |
saturatedFloatToInt()
| Non-trapping float-to-int conversions | |
signExtensions()
| Sign-extension operators | |
simd()
| Fixed-Width SIMD | |
tailCall()
| Tail call | |
threads()
| Threads |

Why are all the tests async?

The technical reason is that some tests might have to be augmented to be asynchronous in the future. For example, Firefox is planning to make a change that would require a

postMessage
call to detect SABs, which are required for threads.

The other reason is that you should be using

WebAssembly.compile
,
WebAssembly.instantiate
, or their streaming versions
WebAssembly.compileStreaming
and
WebAssembly.instantiateStreaming
, which are all asynchronous. You should already be prepared for asynchronous code when using WebAssembly!

Contributing

If you want to contribute a new feature test, all you need to do is create a new folder in

src/detectors
and it will be automatically picked up. The folder must contain a
module.wat
file, which will be compiled using
wabt.js
.
;; Name: 
;; Proposal: 
;; Features: 

(module ;; More WAT code here )

The folder can also contain an optional

index.js
file, whose default export must be an async function. This function can do additional testing in JavaScript and must return a boolean. See the “threads” detector as an example.

License Apache-2.0

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.