From 35816b5121a328dd9944fb0934f04e9b947633e2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 11 May 2014 13:18:20 -0400 Subject: [PATCH] feature(util) add back isArrayBuffer --- lib/client/rest.js | 3 ++- lib/client/zip.js | 8 ++++++-- lib/util.js | 11 +++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/client/rest.js b/lib/client/rest.js index 880f07d3..f91f87f5 100644 --- a/lib/client/rest.js +++ b/lib/client/rest.js @@ -123,12 +123,13 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.getConfig(function(config) { var data, isString = Util.isString(p.data), + isArrayBuffer = Util.isArrayBuffer(p.data), isFile = Util.isFile(p.data); if (Util.isString(p.url)) p.url = decodeURI(p.url); - if (p.data && !isString && !isFile) + if (p.data && !isString && !isArrayBuffer && !isFile) data = Util.stringifyJSON(p.data); else data = p.data; diff --git a/lib/client/zip.js b/lib/client/zip.js index a99dbc98..e0453731 100644 --- a/lib/client/zip.js +++ b/lib/client/zip.js @@ -9,9 +9,13 @@ var Util, Zip, pako; function ZipProto() { this.pack = function(str, callback) { - var buf, deflate, result; + var buf, deflate, result, + isArrayBuffer = Util.isArrayBuffer(str); - buf = utf8AbFromStr(str); + if (isArrayBuffer) + buf = str; + else + buf = utf8AbFromStr(str); deflate = new pako.Deflate({ gzip:true diff --git a/lib/util.js b/lib/util.js index 744746c9..902f9ea6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -578,6 +578,17 @@ return Array.isArray(variable); }; + /** + * functions check is variable is arrayBuffer + * @param variable + */ + this.isArrayBuffer = function(variable) { + var type = this.getType(variable), + is = type === 'arraybuffer'; + + return is; + }; + /** * functions check is variable is boolean * @param variable