From b9c152b6cd558b776ad39e34ca8bcab1a1e2c583 Mon Sep 17 00:00:00 2001 From: Mihal Malostanidis Date: Tue, 3 Oct 2017 00:54:11 +0300 Subject: [PATCH] Fix ArrayBuffer in WebWorker ARRAY_BUFFER constant was set using global ArrayBuffer, but here instance checking is made against root.ArrayBuffer. This breaks WebWorker which has no window. With this simple fix, I am successfully using it in WebWorker. Please tell me if you are interested in a pull request to make injecting into global object explicit and support ES6 modules. --- src/sha512.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sha512.js b/src/sha512.js index a179a3a..9d18b14 100644 --- a/src/sha512.js +++ b/src/sha512.js @@ -184,7 +184,7 @@ return; } var notString = typeof(message) !== 'string'; - if (notString && ARRAY_BUFFER && message instanceof root.ArrayBuffer) { + if (notString && ARRAY_BUFFER && message instanceof ArrayBuffer) { message = new Uint8Array(message); } var code, index = 0, i, length = message.length || 0, blocks = this.blocks;