small utilities that I'm tired of digging from old scripts to put in new ones.
Αυτές είναι όλες οι εκδόσεις αυτού του κώδικα. Προβολή μόνο των εκδόσεων όπου άλλαξε ο κώδικας.
renamed `visit()` to `traverse()`, because it seems slightly more self-explanatory.
added `visit()` to recurse through a json-ish object structure.
Added `makeDraggable` to scaffold boring event plumbing. Don't like the name. whatever.
fix minor brain damage in custom()
custom()
added `decodeEntities()`
log() is now log()/warn()/error(). yay.
Great. Another helpful polyfill (dom-shims) breaks basic browser behavior by refusing to run `element.append()` without arguments. Thanks helpful polyfill for old browsers that's something running in latest chrome.
keep `addStyles()` working even when we run super-early and document.head is still null.
added a `logGroup` function, works along `withLog()` and `log()`, but unlike log(), it collapses its args past the msg.
use a lighter touch in fixConsole.
`fixConsole()` returns a method to undo its changes (and therefore, "unfix" the console object.)
memoize tweaks: - slightly more expansive mkKey() default, - changed semantics to no longer memoize null or undefined values.(I probably have a reason for this, and the nullish coalescing golfing is entirely coincidental. erm.)
unbreaking async contract in `until` and `untilDOM`
until and untilDOM return without waiting if the condition passed is already truthy/the CSS selector is found.
until
untilDOM
add an EZ-cleanup return function to events().
events()
memoization
document is a Node.
document
add `fixConsole()`
Brownian golfing.
gotta commit to the bit. ah! get it?
renamed getHTML/getJSON to fetchHTML/fetchJSON. more pointless golfing.
Some basic network stuff: xhr, getHTML, getJSON, and prefetch methodsNone of them require a @grant.
many user scripts add styles, so here's `addStyles()`. cool.
Example usage:
let [ delta, drag ] = [0,0]; events({ mousedown() { [ delta, drag ] = [0,1] }, mousemove(e) { if (drag) scrollBy(0, delta=-e.movementY) }, mouseup() { drag=0; rAF((_,n) => Math.abs(delta*=0.95)>1 && n(scrollBy(0, delta))) } });
added requestAnimationFrame wrapper
Added some DOM query shortcuts.
Typo fix