From 9f8c2a3fb349cadd9f3e90065a05f74ae9adaee8 Mon Sep 17 00:00:00 2001 From: happylynx Date: Tue, 27 Dec 2016 20:18:36 +0100 Subject: [PATCH] Fix of recognition of ArrayBuffer parameters If js-sha3 is loaded using 'webpack' loader then the top-most fuction is not called with global object (`global` in node, `window` in browsers) and thus `root.ArrayBuffer` is undefined. This patch introduces usage of `ArrayBuffer` without `root` prefix similary to how e.g. `Uint8Array` is already used. --- src/sha3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sha3.js b/src/sha3.js index 3235233..362aade 100644 --- a/src/sha3.js +++ b/src/sha3.js @@ -106,7 +106,7 @@ Keccak.prototype.update = function (message) { var notString = typeof message != 'string'; - if (notString && message.constructor == root.ArrayBuffer) { + if (notString && message instanceof ArrayBuffer) { message = new Uint8Array(message); } var length = message.length, blocks = this.blocks, byteCount = this.byteCount,