From 4640bed36a0661365dd117e5c8fedd6bd68a764c Mon Sep 17 00:00:00 2001 From: waiting <1661926154@qq.com> Date: Sat, 14 Oct 2017 16:26:26 +0800 Subject: [PATCH] fix: ab2string() calculation of array length --- docs/arraybuffer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/arraybuffer.md b/docs/arraybuffer.md index 5d371c0..236f780 100644 --- a/docs/arraybuffer.md +++ b/docs/arraybuffer.md @@ -456,9 +456,9 @@ function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } - const len = bufView.byteLength; - const bstr = new Array(len); const bufView = new Uint16Array(buf); + const len = bufView.length; + const bstr = new Array(len); for (let i = 0; i < len; i++) { bstr[i] = String.fromCharCode.call(null, bufView[i]); }