Skip to content

Commit

Permalink
Invert test
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Aug 21, 2020
1 parent 209852e commit 5877efb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 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.
- ✅ Runs in Node
- ✅ Provided as an ES6 module, CommonJS and UMD module.
- ✅ CSP compatible
- ✅ Only ~550B gzipped
- ✅ Only ~570B gzipped

## Installation

Expand Down
7 changes: 4 additions & 3 deletions src/detectors/threads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

export default async moduleBytes => {
try {
const MessageChannelConstructor = await import("worker_threads")
.then(m => m.MessageChannel)
.catch(() => MessageChannel);
const MessageChannelConstructor =
typeof MessageChannel !== "undefined"
? MessageChannel
: await import("worker_threads").then(m => m.MessageChannel);
// Test for transferability of SABs (needed for Firefox)
// https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
new MessageChannelConstructor().port1.postMessage(new SharedArrayBuffer(1));
Expand Down

0 comments on commit 5877efb

Please sign in to comment.