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 loop = (fn, delay) => { | |
const next = () => setTimeout( | |
() => loop(fn, delay), | |
delay | |
) | |
fn(next) | |
} |
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 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 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 duplicate = (arr, duplications) => arr.reduce((acc, val, i) => { | |
const duplication = duplications[i] | |
for (let i = 0; i<duplication; i++) acc.push(val) | |
return acc | |
}, []) |
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 mousePosition = (() => { | |
let pos = {} | |
const position = (e) => ({ | |
x: e.pageX, | |
y: e.pageY | |
}) | |
document.addEventListener('mousemove', (e) => pos = position(e), false) |
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
%clearfix { | |
&::before, | |
&::after { | |
content: ' '; | |
display: table; | |
} | |
&::after { | |
clear: both; |
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 toClassString = (obj) => Object.keys(obj).filter((key) => obj[key]===true).join(' ').trim() |
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
{ | |
"rules": { | |
"color-no-invalid-hex": true, | |
"function-calc-no-unspaced-operator": true, | |
"function-linear-gradient-no-nonstandard-direction": true, | |
"function-max-empty-lines": 0, | |
"function-parentheses-space-inside": "never", | |
"function-url-quotes": "always", | |
"function-whitespace-after": "always", | |
"function-comma-space-after": "always", |
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 formatNumber = (num, delimiter = ',') => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, delimiter) |
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
mime { | |
.atom application/atom+xml | |
.json application/json | |
.map application/json | |
.topojson application/json | |
.jsonld application/ld+json | |
.rss application/rss+xml | |
.geojson application/vnd.geo+json | |
.rdf application/xml | |
.xml application/xml |
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 hasLocalStorage = () => { | |
const tmp = 'tmp' | |
try { | |
localStorage.setItem(tmp, tmp) | |
localStorage.removeItem(tmp) | |
return true |