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);