Bläddra i källkod

Merge pull request #4378 from acozzette/node-buffer

Revert "Removed mention of Buffer in byteSourceToUint8Array"
Adam Cozzette 7 år sedan
förälder
incheckning
89b5333ad0
1 ändrade filer med 4 tillägg och 0 borttagningar
  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));
   }
 
+  if (data.constructor === Buffer) {
+    return /** @type {!Uint8Array} */(new Uint8Array(data));
+  }
+
   if (data.constructor === Array) {
     data = /** @type {!Array<number>} */(data);
     return /** @type {!Uint8Array} */(new Uint8Array(data));