| const allCustomElements = []; | |
| function isCustomElement(el) { | |
| const isAttr = el.getAttribute('is'); | |
| // Check for <super-button> and <button is="super-button">. | |
| return el.localName.includes('-') || isAttr && isAttr.includes('-'); | |
| } | |
| function findAllCustomElements(nodes) { | |
| for (let i = 0, el; el = nodes[i]; ++i) { |
| var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' + | |
| 'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' + | |
| 'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' + | |
| ': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));'; | |
| try { | |
| eval(str); | |
| } catch(e) { | |
| alert('Your browser does not support ES6!') | |
| } |
| //https://developer.mozilla.org/en-US/docs/Web/Events/resize | |
| ; | |
| (function() { | |
| var throttle = function(type, name, obj_) { | |
| var obj = obj_ || window; | |
| var running = false; | |
| var func = function() { | |
| if (running) { | |
| return; | |
| } |
| /* tslint:disable-next-line */ | |
| let stringifyObj = function (obj: object): any {}; | |
| if (!DEBUG) { | |
| stringifyObj = (obj: object): string => { | |
| const placeholder = "____PLACEHOLDER____"; | |
| const fns: Function[] = []; | |
| let json = JSON.stringify( | |
| obj, | |
| function (_, value: any): any { |
| function timeoutify(fn,delay) { | |
| var intv = setTimeout( function(){ | |
| intv = null; | |
| fn( new Error( "Timeout!" ) ); | |
| }, delay ) | |
| ; | |
| return function() { | |
| // timeout hasn't happened yet? | |
| if (intv) { |
| man -P 'less -p ^READLINE' bash |
| groff -man -T html $(man -w man) > $TMPDIR/man.html | open -f -a 'Google Chrome' $TMPDIR/man.html |
| # From http://vim.wikia.com/wiki/Using_vim_as_a_man-page_viewer_under_Unix | |
| export MANPAGER='col -bx | vim -c ":set ft=man nonu nolist" -R -' |
There's no need to fully parse the xml of entire clearleap api responses to JSON. And there doesn't seem to be a compelling reason to use xml2json, unless api responses need to be rendered on the back end in an isomorphic app. Usually, we just want to pluck certain values out, massage them a bit, and add them as properties of an object/structure better suited to presentation.
At its simplest, this can be done with a function that takes an instance of Node, performs DOM querying logic to retrieve and aggregate values from elements and attributes, and then returns a single value.
This gist shows a way to reuse and compose pure functions of this variety to converge parsing operations for invidual values into a final object. Because only pure functions are involved, presumably parsing could be parallelized with web workers (https://adambom.github.io/parallel.js/). Each pure function involved is also automatically memoized and passed wi