From f8005a5d5ad41daebe7630fc39e3b8a19eb3bd87 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 9 Mar 2018 15:07:04 -0800 Subject: Revert "Removed mention of Buffer in byteSourceToUint8Array" This reverts commit f00e06c95bc117fb2ed0ca56c96041c93039f1fe. Although Node Buffers are not covered by the tests, it seems that there are users relying on them, so we need to add back in support for them. This fixes issue #4359. --- js/binary/utils.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js') 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} */(data); return /** @type {!Uint8Array} */(new Uint8Array(data)); -- cgit v1.2.3