]> zoso.dev Git - buffer.git/commitdiff
add back support for browsers without SharedArrayBuffer
authorFeross Aboukhadijeh <feross@feross.org>
Fri, 6 Mar 2020 19:49:35 +0000 (11:49 -0800)
committerFeross Aboukhadijeh <feross@feross.org>
Fri, 6 Mar 2020 19:49:35 +0000 (11:49 -0800)
SharedArrayBuffer support originally added in https://github.com/feross/buffer/pull/259

index.js

index 8f8b708111eaf9cb9eaa0b4bb2e3ab3fec9e448b..4ec559548199690df961a0dba5c667ae04bb8246 100644 (file)
--- a/index.js
+++ b/index.js
@@ -142,8 +142,9 @@ function from (value, encodingOrOffset, length) {
     return fromArrayBuffer(value, encodingOrOffset, length)
   }
 
-  if (isInstance(value, SharedArrayBuffer) ||
-      (value && isInstance(value.buffer, SharedArrayBuffer))) {
+  if (typeof SharedArrayBuffer !== 'undefined' &&
+      (isInstance(value, SharedArrayBuffer) ||
+      (value && isInstance(value.buffer, SharedArrayBuffer)))) {
     return fromArrayBuffer(value, encodingOrOffset, length)
   }