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
function throttle(callback, fps = 60) { | |
const frameTime = 1000 / fps; | |
let lastTime = window.performance.now(); | |
return function run() { | |
window.requestAnimationFrame(run); | |
const currentTime = window.performance.now(); | |
const elapsedTime = currentTime - lastTime; | |
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
.neon-text { | |
color: #fff; | |
text-shadow: | |
0 0 7px #fff, | |
0 0 10px #fff, | |
0 0 21px #fff, | |
0 0 42px #0fa, | |
0 0 82px #0fa, | |
0 0 92px #0fa, | |
0 0 102px #0fa, |
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
if (!Object.prototype[Symbol.iterator]) { | |
Object.prototype[Symbol.iterator] = function* () { | |
for (let key in this) { | |
yield this[key]; | |
} | |
}; | |
} |
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 fetchWithRetries = async (url, options, retryCount = 0) => { | |
const { maxRetries = 3, ...remainingOptions } = options; | |
try { | |
return await fetch(url, remainingOptions); | |
} catch (error) { | |
if (retryCount < maxRetries) { | |
return fetchWithRetries(url, options, retryCount + 1); | |
} |
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 cities = new Map([ | |
['MG', 'Belzante'], | |
['SP', 'Sampa'] | |
]); | |
const getCity = city => cities.get(city) ?? 'Not found'; |
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
import { defer } from 'rxjs'; | |
import { map } from 'rxjs/operators'; | |
export const bufferMaxCount = (count = 0) => source => defer(() => { | |
let buffer = []; | |
return source.pipe( | |
map(next => buffer = [next, ...buffer.slice(0, count - 1)]) | |
); | |
}); |
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
export const delay = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds)); |
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
function Seal(constructor: Function) { | |
Object.seal(constructor); | |
Object.seal(constructor.prototype); | |
} |
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
function Freeze(constructor: Function) { | |
Object.freeze(constructor); | |
Object.freeze(constructor.prototype); | |
} |
NewerOlder