Jelajahi Sumber

Merge pull request #5433 from davido/remove_mention_of_buffer_in_utils.js

Remove mention of Buffer in utils.js
Adam Cozzette 6 tahun lalu
induk
melakukan
66dc42d891
1 mengubah file dengan 4 tambahan dan 3 penghapusan
  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);