@resk/core
Version:
An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla
2 lines • 2.64 kB
JavaScript
;var m=require('../isNonNullString');require('../string');var p=require('qs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);var p__default=/*#__PURE__*/_interopDefault(p);var g=Object.defineProperty;var f=Object.getOwnPropertySymbols;var l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;var c=(r,t,n)=>t in r?g(r,t,{enumerable:true,configurable:true,writable:true,value:n}):r[t]=n,a=(r,t)=>{for(var n in t||(t={}))l.call(t,n)&&c(r,n,t[n]);if(f)for(var n of f(t))u.call(t,n)&&c(r,n,t[n]);return r};const y=(r,t=true)=>{if(typeof r!="string")return "";let n=j(r);return r=typeof n.search=="string"?n.search:"",t&&r?"?"+r.ltrim("?"):(r=r.trim().ltrim("?").rtrim("?"),r)},h=function(r,t={}){return typeof r!="string"?{}:p__default.default.parse(y(r,false),a({allowSparse:true},Object.assign({},t)))},d=function(r,t=false){return typeof r!="string"?"":(r=r.replace(/#.*$/,"").replace(/\?.*$/,""),t===true?decodeURIComponent(r):r)},b={indices:false,arrayFormat:"brackets",encodeValuesOnly:true};function A(r,t,n,s={}){if(typeof r!="string"||!r)return "";let e=h(r);return r=d(r),typeof t=="object"?(t||(t={}),s=typeof s=="object"&&s?s:typeof n=="object"&&n?n:{}):typeof t=="string"&&(t={[t]:n}),typeof t=="object"&&t&&!Array.isArray(t)&&Object.assign(e,t),r+"?"+p__default.default.stringify(e,a(a({},b),Object.assign({},s)))}function C(r,t=false){if(r==null||typeof r!="object")return "";function n(e,o){if(Array.isArray(e)){e.forEach(function(i){n(i,o+"[]");});return}if(e!==null&&typeof e=="object"){Object.keys(e).forEach(function(i){n(e[i],o+"["+i+"]");});return}s.push((t?encodeURIComponent(o):o)+"="+(t?encodeURIComponent(e):e));}const s=[];return Object.keys(r).forEach(function(e){n(r[e],e);}),s.join("&")}const j=r=>{if(typeof r!="string")return {};var t=r.match(/^(([^:\/?#]+:)?(?:\/\/((?:([^\/?#:]*):([^\/?#:]*)@)?([^\/?#:]*)(?::([^\/?#:]*))?)))?([^?#]*)(\?[^#]*)?(#.*)?$/);let n=t?{hash:t[10]||"",host:t[3]||"",hostname:t[6]||"",href:t[0]||"",origin:t[1]||"",pathname:t[8]||(t[1]?"/":""),port:t[7]||"",protocol:t[2]||"",search:t[9]||"",username:t[4]||"",password:t[5]||""}:{};return n.protocol&&n.protocol.length==2&&(n.protocol="file:///"+n.protocol.toUpperCase(),n.origin=n.protocol+"//"+n.host),n.protocol&&(n.href=n.origin+n.pathname+n.search+n.hash),n},P=r=>m__default.default(r)?!!/^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/.test(r):false;
exports.extractQueryString=y;exports.getQueryParams=h;exports.isValidUrl=P;exports.objectToQueryString=C;exports.parseURI=j;exports.removeQueryString=d;exports.setQueryParams=A;