-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashquery.amd.js.map
1 lines (1 loc) · 3.22 KB
/
hashquery.amd.js.map
1
{"version":3,"file":"hashquery.amd.js","sources":["src/hashquery.ts"],"sourcesContent":["'use strict';\n\ninterface Map {\n [key: string]: string;\n}\n\nfunction getWindowHash(): string {\n return window.location.hash.substr(1);\n}\n\nfunction removeHash () { \n history.pushState(\"\", document.title, window.location.pathname + window.location.search);\n}\n\nfunction setWindowHash(queryString: string): void {\n if (!queryString || queryString === '#') {\n removeHash();\n return;\n }\n window.location.hash = queryString;\n}\n\nfunction parseQuery(queryString: string): Map {\n const pieces: string[] = queryString ? queryString.split('&') : [];\n const map: Map = {};\n pieces.forEach((piece) => {\n const keyVal = piece.split('=');\n const key = decodeURIComponent(keyVal[0]);\n if (!key) return;\n const val = decodeURIComponent(keyVal[1]);\n map[key] = val;\n });\n return map;\n}\n\nfunction prepareQuery(map: Map): string {\n let queryString: string = '';\n for (let key in map) {\n if (!key) continue;\n const val = map[key];\n queryString += '&' + encodeURIComponent(key) + '=' + encodeURIComponent(val);\n }\n return queryString.substr(1);\n}\n\nexport function get(val: string): string {\n const queryString = getWindowHash();\n const map: Map = parseQuery(queryString);\n return map[val];\n}\n\nexport function set4Href(key: string, val: string): string {\n const queryString = getWindowHash();\n const map: Map = parseQuery(queryString);\n map[key] = val;\n const newQueryString = prepareQuery(map);\n return '#' + newQueryString;\n}\n\nexport function set(key: string, val: string): void {\n setWindowHash(set4Href(key, val));\n}\n\nexport function del4Href(key: string) {\n const queryString = getWindowHash();\n const map: Map = parseQuery(queryString);\n delete map[key];\n const newQueryString = prepareQuery(map);\n return '#' + newQueryString;\n}\n\nexport function del(key: string) {\n setWindowHash(del4Href(key));\n}\n\n\n\n"],"names":["window","location","hash","substr","history","pushState","document","title","pathname","search","queryString","removeHash","pieces","split","map","forEach","piece","keyVal","key","decodeURIComponent","val","encodeURIComponent","parseQuery","getWindowHash","prepareQuery","setWindowHash","set4Href","del4Href"],"mappings":"2CAMA,cACI,MAAOA,QAAOC,SAASC,KAAKC,OAAO,GAGvC,aACIC,QAAQC,UAAU,GAAIC,SAASC,MAAOP,OAAOC,SAASO,SAAWR,OAAOC,SAASQ,QAGrF,WAAuBC,GACnB,IAAKA,GAA+B,MAAhBA,EAEhB,WADAC,IAGJX,QAAOC,SAASC,KAAOQ,EAG3B,WAAoBA,GAChB,GAAME,GAAmBF,EAAcA,EAAYG,MAAM,QACnDC,IAQN,OAPAF,GAAOG,QAAQ,SAACC,GACZ,GAAMC,GAASD,EAAMH,MAAM,KACrBK,EAAMC,mBAAmBF,EAAO,GACtC,IAAKC,EAAL,CACA,GAAME,GAAMD,mBAAmBF,EAAO,GACtCH,GAAII,GAAOE,KAERN,EAGX,WAAsBA,GAClB,GAAIJ,GAAsB,EAC1B,KAAK,GAAIQ,KAAOJ,GACZ,GAAKI,EAAL,CACA,GAAME,GAAMN,EAAII,EAChBR,IAAe,IAAMW,mBAAmBH,GAAO,IAAMG,mBAAmBD,GAE5E,MAAOV,GAAYP,OAAO,GAG9B,WAAoBiB,GAGhB,MADiBE,GADGC,KAETH,GAGf,WAAyBF,EAAaE,GAClC,GAAMV,GAAca,IACdT,EAAWQ,EAAWZ,EAG5B,OAFAI,GAAII,GAAOE,EAEJ,IADgBI,EAAaV,GAIxC,WAAoBI,EAAaE,GAC7BK,EAAcC,EAASR,EAAKE,IAGhC,WAAyBF,GACrB,GAAMR,GAAca,IACdT,EAAWQ,EAAWZ,EAG5B,cAFOI,GAAII,GAEJ,IADgBM,EAAaV,GAIxC,WAAoBI,GAChBO,EAAcE,EAAST"}