From: Feross Aboukhadijeh Date: Fri, 6 Mar 2020 19:49:35 +0000 (-0800) Subject: add back support for browsers without SharedArrayBuffer X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=ae2ab6740394bc60c0e28fc5eca67b2e663a688a;p=buffer.git add back support for browsers without SharedArrayBuffer SharedArrayBuffer support originally added in https://github.com/feross/buffer/pull/259 --- diff --git a/index.js b/index.js index 8f8b708..4ec5595 100644 --- 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) }