Skip to content

Commit a2da044

Browse files
committed
Merge branch 'features/bigint-parameters'
2 parents a1d6719 + 625287c commit a2da044

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A small library to detect which features of WebAssembly are supported.
66
- ✅ Runs in Node
77
- ✅ Provided as an ES6 module, CommonJS and UMD module.
88
- ✅ CSP compatible
9-
- ✅ Only ~504B gzipped
9+
- ✅ Only ~580B gzipped
1010

1111
## Installation
1212

@@ -45,6 +45,7 @@ All detectors return a `Promise<bool>`.
4545

4646
| Function | Proposal |
4747
| ----------------------- | ------------------------------------------------------------------------------------------------------------ |
48+
| `bigInt()` | [BigInt integration](https://github.com/WebAssembly/JS-BigInt-integration) |
4849
| `bulkMemory()` | [Bulk memory operations](https://github.com/webassembly/bulk-memory-operations) |
4950
| `exceptions()` | [Exception handling](https://github.com/WebAssembly/exception-handling) |
5051
| `multiValue()` | [Multi-value](https://github.com/WebAssembly/multi-value) |

src/detectors/big-int/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
export default async function(bytes) {
15+
try {
16+
const n = BigInt(0);
17+
const instance = await WebAssembly.instantiate(bytes);
18+
return instance.instance.exports.b(n) === n;
19+
} catch {
20+
return false;
21+
}
22+
}

src/detectors/big-int/module.wat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
;; Name: BigInt integration
2+
;; Proposal: https://github.com/WebAssembly/JS-BigInt-integration
3+
4+
(module
5+
(func (export "b") (param i64) (result i64)
6+
local.get 0
7+
)
8+
)

test/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async function run() {
4343
await checkFeature("simd");
4444
await checkFeature("tailCall");
4545
await checkFeature("threads");
46+
await checkFeature("bigInt");
4647
}
4748

4849
run();

0 commit comments

Comments
 (0)