Created
December 2, 2018 01:36
-
-
Save tomhodgins/4c557392138f934180b1d58aad101101 to your computer and use it in GitHub Desktop.
This file contains 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
// add map, filter, reduce to NodeList | |
[ | |
'map', | |
'filter', | |
'reduce', | |
'includes', | |
'every', | |
'some' | |
].forEach(method => | |
NodeList.prototype[method] = Array.prototype[method] | |
) | |
// Logging | |
l = log = console.log | |
d = dir = console.dir | |
g = group = (name, ...strings) => { | |
console.group(name) | |
strings.forEach(string => console.log(string)) | |
console.groupEnd() | |
} | |
// Finding elements | |
q = qsa = document.querySelectorAll.bind(document) | |
qs = document.querySelector.bind(document) | |
// Adding event listeners | |
ael = window.addEventListener.bind(window) | |
Node.prototype.ael = Node.prototype.addEventListener | |
NodeList.prototype.ael = function() { | |
this.forEach(node => node.ael(...arguments)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment