From 54abb282b29a4ddd39cd737eca4780da700fa713 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 12 May 2023 21:05:49 -0700 Subject: [PATCH 1/2] Add detector for type reflection --- README.md | 64 +++++++++++++------------- src/detectors/type-reflection/index.js | 22 +++++++++ 2 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 src/detectors/type-reflection/index.js diff --git a/README.md b/README.md index 2da8625..fafe995 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A small library to detect which features of WebAssembly are supported. - ✅ Tree-shakable (only bundle the detectors you use) - ✅ Provided as an ES6, CommonJS and UMD module. - ✅ CSP compatible -- ✅ All detectors add up to only ~680B gzipped +- ✅ All detectors add up to only ~700B gzipped ## Installation @@ -18,13 +18,13 @@ npm install -g wasm-feature-detect ```html ``` @@ -32,8 +32,8 @@ npm install -g wasm-feature-detect ```html ``` @@ -42,9 +42,9 @@ If required, there’s also a UMD version ```html ``` @@ -52,25 +52,27 @@ If required, there’s also a UMD version All detectors return a `Promise`. -| Function | Proposal | -| ------------------------ | ------------------------------------------------------------------------------------------------------------ | -| `bigInt()` | [BigInt integration](https://github.com/WebAssembly/JS-BigInt-integration) | -| `bulkMemory()` | [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) | -| `exceptions()` | [Exception handling](https://github.com/WebAssembly/exception-handling) | -| `extendedConst()` | [Extented Const Expressesions](https://github.com/WebAssembly/extended-const) | -| `gc()` | [Garbage Collection](https://github.com/WebAssembly/gc) | -| `jspi()` | [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration) | -| `memory64()` | [Memory64](https://github.com/WebAssembly/memory64) | -| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) | -| `mutableGlobals()` | [Importable/Exportable mutable globals]() | -| `referenceTypes()` | [Reference Types](https://github.com/WebAssembly/reference-types) | -| `relaxedSimd()` | [Relaxed SIMD](https://github.com/webassembly/relaxed-simd) | -| `saturatedFloatToInt()` | [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) | -| `signExtensions()` | [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) | -| `simd()` | [Fixed-Width SIMD](https://github.com/webassembly/simd) | -| `streamingCompilation()` | [Streaming Compilation](https://webassembly.github.io/spec/web-api/index.html#streaming-modules) | -| `tailCall()` | [Tail call](https://github.com/webassembly/tail-call) | -| `threads()` | [Threads](https://github.com/webassembly/threads) | +| Function | Proposal | +| --- | --- | +| `bigInt()` | [BigInt integration](https://github.com/WebAssembly/JS-BigInt-integration) | +| `bulkMemory()` | [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) | +| `exceptions()` | [Exception handling](https://github.com/WebAssembly/exception-handling) | +| `extendedConst()` | [Extented Const Expressesions](https://github.com/WebAssembly/extended-const) | +| `gc()` | [Garbage Collection](https://github.com/WebAssembly/gc) | +| `jspi()` | [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration) | +| `memory64()` | [Memory64](https://github.com/WebAssembly/memory64) | +| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) | +| `mutableGlobals()` | [Importable/Exportable mutable globals]() | +| `referenceTypes()` | [Reference Types](https://github.com/WebAssembly/reference-types) | +| `relaxedSimd()` | [Relaxed SIMD](https://github.com/webassembly/relaxed-simd) | +| `saturatedFloatToInt()` | [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) | +| `signExtensions()` | [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) | +| `simd()` | [Fixed-Width SIMD](https://github.com/webassembly/simd) | +| `streamingCompilation()` | [Streaming Compilation](https://webassembly.github.io/spec/web-api/index.html#streaming-modules) | +| `tailCall()` | [Tail call](https://github.com/webassembly/tail-call) | +| `threads()` | [Threads](https://github.com/webassembly/threads) | +| `typeReflection()` | [Type Reflection](https://github.com/WebAssembly/js-types) | + ## Why are all the tests async? diff --git a/src/detectors/type-reflection/index.js b/src/detectors/type-reflection/index.js new file mode 100644 index 0000000..197c83c --- /dev/null +++ b/src/detectors/type-reflection/index.js @@ -0,0 +1,22 @@ +/** + * Copyright 2023 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +;; Name: Type Reflection +;; Proposal: https://github.com/WebAssembly/js-types +;; Features: type-reflection +*/ + +export default async () => { + return "Function" in WebAssembly; +}; From 6e6fad513735392c83c262d6e68311a34e35b605 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 15 May 2023 15:04:28 -0700 Subject: [PATCH 2/2] Format readme --- README.md | 63 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index fafe995..6521e82 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ npm install -g wasm-feature-detect ```html ``` @@ -32,8 +32,8 @@ npm install -g wasm-feature-detect ```html ``` @@ -42,9 +42,9 @@ If required, there’s also a UMD version ```html ``` @@ -52,27 +52,26 @@ If required, there’s also a UMD version All detectors return a `Promise`. -| Function | Proposal | -| --- | --- | -| `bigInt()` | [BigInt integration](https://github.com/WebAssembly/JS-BigInt-integration) | -| `bulkMemory()` | [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) | -| `exceptions()` | [Exception handling](https://github.com/WebAssembly/exception-handling) | -| `extendedConst()` | [Extented Const Expressesions](https://github.com/WebAssembly/extended-const) | -| `gc()` | [Garbage Collection](https://github.com/WebAssembly/gc) | -| `jspi()` | [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration) | -| `memory64()` | [Memory64](https://github.com/WebAssembly/memory64) | -| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) | -| `mutableGlobals()` | [Importable/Exportable mutable globals]() | -| `referenceTypes()` | [Reference Types](https://github.com/WebAssembly/reference-types) | -| `relaxedSimd()` | [Relaxed SIMD](https://github.com/webassembly/relaxed-simd) | -| `saturatedFloatToInt()` | [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) | -| `signExtensions()` | [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) | -| `simd()` | [Fixed-Width SIMD](https://github.com/webassembly/simd) | -| `streamingCompilation()` | [Streaming Compilation](https://webassembly.github.io/spec/web-api/index.html#streaming-modules) | -| `tailCall()` | [Tail call](https://github.com/webassembly/tail-call) | -| `threads()` | [Threads](https://github.com/webassembly/threads) | -| `typeReflection()` | [Type Reflection](https://github.com/WebAssembly/js-types) | - +| Function | Proposal | +| ------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `bigInt()` | [BigInt integration](https://github.com/WebAssembly/JS-BigInt-integration) | +| `bulkMemory()` | [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) | +| `exceptions()` | [Exception handling](https://github.com/WebAssembly/exception-handling) | +| `extendedConst()` | [Extented Const Expressesions](https://github.com/WebAssembly/extended-const) | +| `gc()` | [Garbage Collection](https://github.com/WebAssembly/gc) | +| `jspi()` | [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration) | +| `memory64()` | [Memory64](https://github.com/WebAssembly/memory64) | +| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) | +| `mutableGlobals()` | [Importable/Exportable mutable globals]() | +| `referenceTypes()` | [Reference Types](https://github.com/WebAssembly/reference-types) | +| `relaxedSimd()` | [Relaxed SIMD](https://github.com/webassembly/relaxed-simd) | +| `saturatedFloatToInt()` | [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) | +| `signExtensions()` | [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) | +| `simd()` | [Fixed-Width SIMD](https://github.com/webassembly/simd) | +| `streamingCompilation()` | [Streaming Compilation](https://webassembly.github.io/spec/web-api/index.html#streaming-modules) | +| `tailCall()` | [Tail call](https://github.com/webassembly/tail-call) | +| `threads()` | [Threads](https://github.com/webassembly/threads) | +| `typeReflection()` | [Type Reflection](https://github.com/WebAssembly/js-types) | ## Why are all the tests async?