diff options
-rw-r--r-- | js/binary/utils.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/js/binary/utils.js b/js/binary/utils.js index 87570ff8..55a9ccd4 100644 --- a/js/binary/utils.js +++ b/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)); |