From 24e9149543c6275f54a5cd0ccb111024e37ceedc Mon Sep 17 00:00:00 2001 From: ruanyf Date: Sun, 15 Oct 2017 09:37:12 +0800 Subject: [PATCH] docs(arraybuffer): edit ab2str --- docs/arraybuffer.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/arraybuffer.md b/docs/arraybuffer.md index 236f780..85daa28 100644 --- a/docs/arraybuffer.md +++ b/docs/arraybuffer.md @@ -452,17 +452,7 @@ Float64Array.BYTES_PER_ELEMENT // 8 ```javascript // ArrayBuffer转为字符串,参数为ArrayBuffer对象 function ab2str(buf) { - if (buf && buf.byteLength < 128000) { // limit max length avoid overhead - return String.fromCharCode.apply(null, new Uint16Array(buf)); - } - - 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]); - } - return bstr.join(''); + return String.fromCharCode.apply(null, new Uint16Array(buf)); } // 字符串转为ArrayBuffer对象,参数为字符串