浏览代码

utils.js: Fix closure compiler error

Apply changes from this commit:

"Integrated internal changes from Google"
13fd045dbb2b4dacea32be162a41d5a4b0d1802f
David Ostrovsky 6 年之前
父节点
当前提交
da775bcb38
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      js/binary/utils.js

+ 4 - 3
js/binary/utils.js

@@ -971,9 +971,10 @@ jspb.utils.byteSourceToUint8Array = function(data) {
     return /** @type {!Uint8Array} */(new Uint8Array(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) {
   if (data.constructor === Array) {
     data = /** @type {!Array<number>} */(data);
     data = /** @type {!Array<number>} */(data);