瀏覽代碼

Merge pull request #4378 from acozzette/node-buffer

Revert "Removed mention of Buffer in byteSourceToUint8Array"
Adam Cozzette 7 年之前
父節點
當前提交
89b5333ad0
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      js/binary/utils.js

+ 4 - 0
js/binary/utils.js

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