Skip to content

Commit

Permalink
Merge pull request #70 from hoodmane/multi-memory
Browse files Browse the repository at this point in the history
Add feature detection for Multiple Memories proposal
  • Loading branch information
tomayac authored Oct 18, 2023
2 parents b34b628 + a726d06 commit dc1d3e0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~700B gzipped
- ✅ All detectors add up to only ~740B gzipped

## Installation

Expand Down Expand Up @@ -61,6 +61,7 @@ All detectors return a `Promise<bool>`.
| `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) |
| `multiMemory()` | [Multiple Memories](https://github.com/WebAssembly/multi-memory) |
| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) |
| `mutableGlobals()` | [Importable/Exportable mutable globals]() |
| `referenceTypes()` | [Reference Types](https://github.com/WebAssembly/reference-types) |
Expand Down
39 changes: 39 additions & 0 deletions src/detectors/multi-memory/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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: Multiple Memories
;; Proposal: https://github.com/WebAssembly/multi-memory
;; Features: multi-memory
*/

export default async () => {
try {
new WebAssembly.Module(
// prettier-ignore
new Uint8Array([
// magic number
0x00, 0x61, 0x73, 0x6d,
0x01, 0x00, 0x00, 0x00,
0x05, // memory section id
0x05, // section length
0x02, // 2 memories
0x00, 0x00, // 1st has no max, min of 0
0x00, 0x00, // 2nd has no max, min of 0
]),
);
return true;
} catch (e) {
return false;
}
};

0 comments on commit dc1d3e0

Please sign in to comment.