UNPKG

qss

Version:

A tiny (305B) browser utility for stringifying a query Object.

1 lines 707 B
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.qss={})}(this,function(e){function n(e){if(!e)return"";var n=decodeURIComponent(e);return"false"!==n&&("true"===n||(0*+n==0?+n:n))}e.decode=function(e){for(var o,t,f={},i=e.split("&");o=i.shift();)void 0!==f[t=(o=o.split("=")).shift()]?f[t]=[].concat(f[t],n(o.shift())):f[t]=n(o.shift());return f},e.encode=function(e,n){var o,t,f,i="";for(o in e)if(void 0!==(f=e[o]))if(Array.isArray(f))for(t=0;t<f.length;t++)i&&(i+="&"),i+=encodeURIComponent(o)+"="+encodeURIComponent(f[t]);else i&&(i+="&"),i+=encodeURIComponent(o)+"="+encodeURIComponent(f);return(n||"")+i}});