npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wasm-feature-detect

v1.8.0

Published

A small library to detect which features of WebAssembly are supported in your current browser.

Downloads

906,874

Readme

WebAssembly Feature Detection

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

  • ✅ Runs in browsers, Node and Deno
  • ✅ Tree-shakable (only bundle the detectors you use)
  • ✅ Provided as an ES6, CommonJS and UMD module.
  • ✅ CSP compatible
  • ✅ All detectors add up to only ~970B gzipped

Installation

npm install -g wasm-feature-detect

Usage

<script type="module">
	import { simd } from "wasm-feature-detect";

	if (await simd()) {
		/* SIMD support */
	} else {
		/* No SIMD support */
	}
</script>

Hotlinking from Unpkg

<script type="module">
	import { simd } from "https://unpkg.com/wasm-feature-detect?module";
	// ...
</script>

If required, there’s also a UMD version

<script src="https://unpkg.com/wasm-feature-detect/dist/umd/index.js"></script>
<script>
	if (await wasmFeatureDetect.simd()) {
	  // ...
	}
</script>

Detectors

All detectors return a Promise<bool>.

| Function | Proposal | | --------------------------- | ------------------------------------------------------------------------------------------------------------ | | bigInt() | BigInt integration | | bulkMemory() | Bulk memory operations | | exceptions() | Legacy Exception Handling | | exceptionsFinal() | Exception Handling with exnref | | extendedConst() | Extented Const Expressesions | | gc() | Garbage Collection | | jsStringBuiltins() | JS String Builtins Proposal for WebAssembly | | jspi() | JavaScript Promise Integration | | memory64() | Memory64 | | multiMemory() | Multiple Memories | | multiValue() | Multi-value | | mutableGlobals() | Importable/Exportable mutable globals | | referenceTypes() | Reference Types | | relaxedSimd() | Relaxed SIMD | | saturatedFloatToInt() | Non-trapping float-to-int conversions | | signExtensions() | Sign-extension operators | | simd() | Fixed-Width SIMD | | streamingCompilation() | Streaming Compilation | | tailCall() | Tail call | | threads() | Threads | | typeReflection() | Type Reflection | | typedFunctionReferences() | Typed function references |

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 may contain a module.wat file, which will be compiled using wabt.js.

;; Name: <Name of the feature for the README>
;; Proposal: <Link to the proposal’s explainer/repo>
;; Features: <Space-separated list of WasmFeatures from wabt.js>

(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. It must contain at least one of module.wat or index.js.


License Apache-2.0