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
<input autocapitalize="off" ...> |
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
<input autocorrect="off" ...> |
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
const hasClassNames = (elem, classNames) => classNames.filter((className) => elem.classList.contains(className)).length>0 |
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
const createArray = (length) => Array.apply(null, Array(length)) |
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
const repeat = (fn, times) => { | |
fn() | |
--times && repeat(fn, times) | |
} |
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
const fifo = (length) => { | |
const arr = [] | |
return (value) => { | |
if (value===undefined) return arr | |
if (arr.length>=length) arr.shift() | |
arr.push(value) |
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
const randomColor = () => { | |
const random = (min, max) => Math.random() * (max - min) + min | |
const h = Math.floor(random(0, 360)) | |
const s = Math.floor(random(50, 100)) | |
const l = Math.floor(random(50, 100)) | |
return `hsl(${ h }, ${ s }%, ${ l }%)` | |
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
const loop = (fn, delay) => { | |
const next = () => setTimeout( | |
() => loop(fn, delay), | |
delay | |
) | |
fn(next) | |
} |
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
const queue = (query, delay, next) => { | |
if (query.length===0) return next() | |
query[0]() | |
const trimmed = query.slice(1) | |
setTimeout(() => exec(trimmed, delay, next), delay) |
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
const mousePosition = (() => { | |
let pos = {} | |
const position = (e) => ({ | |
x: e.pageX, | |
y: e.pageY | |
}) | |
document.addEventListener('mousemove', (e) => pos = position(e), false) |