From da775bcb3825f3c8a41f10a332cfece5830eb881 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Fri, 7 Dec 2018 21:56:56 +0100 Subject: [PATCH] utils.js: Fix closure compiler error Apply changes from this commit: "Integrated internal changes from Google" 13fd045dbb2b4dacea32be162a41d5a4b0d1802f --- js/binary/utils.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/binary/utils.js b/js/binary/utils.js index 55a9ccd4c..99283c2c9 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js @@ -971,9 +971,10 @@ jspb.utils.byteSourceToUint8Array = function(data) { return /** @type {!Uint8Array} */(new Uint8Array(data)); } - if (data.constructor === Buffer) { - return /** @type {!Uint8Array} */(new Uint8Array(data)); - } + if (typeof Buffer != 'undefined' && data.constructor === Buffer) { + return /** @type {!Uint8Array} */ ( + new Uint8Array(/** @type {?} */ (data))); + } if (data.constructor === Array) { data = /** @type {!Array} */(data);