aboutsummaryrefslogtreecommitdiffhomepage
path: root/js
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2018-03-09 15:07:04 -0800
committerGravatar Adam Cozzette <acozzette@google.com>2018-03-09 15:08:52 -0800
commitf8005a5d5ad41daebe7630fc39e3b8a19eb3bd87 (patch)
tree8aa0db47a5179240c0cace472062b8b52bddef62 /js
parent8e44a86facd0f42af7a3c0c47f8133f78f037269 (diff)
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.
Diffstat (limited to 'js')
-rw-r--r--js/binary/utils.js4
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));