This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createDelimitedParams(obj = {}, keyValDelimiter = '=', paramDelimiter = '&') { | |
| return Object.entries(obj) | |
| .map(entry => entry.join(keyValDelimiter)) | |
| .join(paramDelimiter); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const parseXML = (xmlStr) => { | |
| const parser = new DOMParser(); | |
| const doc = parser.parseFromString(xmlStr, 'application/xml'); | |
| const errorNode = doc.querySelector('parsererror'); | |
| if (errorNode) { | |
| console.log('error while parsing'); | |
| return errorNode; | |
| } else { | |
| console.log('parsing complete: ' + doc.documentElement.nodeName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ciMatch(prop = '', str = '') { | |
| return str.localeCompare(prop, 'en', { sensitivity: 'base' }) === 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ten = 'no numbers'.length; | |
| [...Array(ten * ten).keys()].forEach(i => console.log(++i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ((j,b)=>{j.t=!j.t;const f=j.t?b.addEventListener:b.removeEventListener;console.log('remove mode %s',j.t?'on':'off');j.rE=j.rE||(({target:el})=>{console.log('removing:',el);el.parentNode.removeChild(el);});f('click',j.rE);})(window.JMT=window.JMT||{},document.body); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function validateJWT(jwt) { | |
| let payload = {}, valid = false | |
| try { | |
| [, payload] = jwt.split('.').slice(0,2).map(p => JSON.parse(atob(p))) | |
| valid = true | |
| } catch (error) {} | |
| return { jwt, payload, valid } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getDeep(obj, key) { | |
| return key.split('.').reduce((o, x) => { | |
| return (o || {})[x]; | |
| }, obj); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getFullname = u => [u.first, u.middle, u.last].filter(Boolean).join(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getByProperty(obj, prop) { | |
| if (typeof obj === "object") { | |
| return Object.keys(obj).reduce( (a, c) => { | |
| if (c === prop) { | |
| a = a.concat(obj[c]); | |
| } | |
| return a.concat( | |
| getByProperty(obj[c], prop) || [] | |
| ); | |
| }, []); |
NewerOlder