소스 검색

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));
   }
 
-  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<number>} */(data);