Revert "Removed mention of Buffer in byteSourceToUint8Array"

This reverts commit f00e06c95b.

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.
This commit is contained in:
Adam Cozzette 2018-03-09 15:07:04 -08:00
parent 8e44a86fac
commit f8005a5d5a

View File

@ -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));