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 http2 = require('http2'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const zlib = require('zlib'); | |
const brotli = require('brotli'); // npm package | |
const PORT = 3032; | |
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares | |
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/'); | |
const cache = {}; |
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
let array = [] | |
// Joins two or more arrays, and returns a copy of the joined arrays | |
array.concat(otherArray) | |
// Copies array elements within the array, to and from specified positions | |
array.copyWithin(target, start, end) | |
// Returns a key/value pair Array Iteration Object | |
array.entries() |
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
[...Array(10).keys()] | |
// [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
[...Array({ one:'1' }, { two: '2' }, { three: '3' }).keys()] | |
// [1, 2, 3] | |
let arr1 = [1, 2, 3] | |
let arr2 = [2, 3, 4] |
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 obj = { | |
name: 'Erdem', | |
surname: 'Arslan' | |
} | |
const onChange = (watch, callback) => { | |
const handler = { | |
get (target, prop, receiver) { | |
callback(target, prop, receiver) |
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
export default () => { | |
let docElem = document.documentElement | |
let active = false | |
let hasDeactivated = false | |
let eventsBound = false | |
let mouseWheelHandler | |
let scrollHandler | |
const scrollCallback = (offset, event, callback) => { |
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 scrollDistance = (callback, refresh) => { | |
if (!callback || typeof callback !== 'function') return | |
let isScrolling, start, end, distance | |
window.addEventListener('scroll', event => { | |
if (!start) { | |
start = window.pageYOffset | |
} |
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
// Long Polling | |
let ID = 1 | |
const foo = document.createElement('p') | |
async function timeout (callback, delay) { | |
return await setTimeout(callback, delay) | |
} | |
function polling () { | |
return timeout(() => { |
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
/** | |
* @param {number} range | |
*/ | |
function* generator (range) { | |
let i = 0 | |
while (i < range) { | |
i += 1 | |
yield i | |
} |
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
export default class Spinner { | |
#elements: NodeListOf<HTMLElement> = document.querySelectorAll('[data-zm-spinner]') | |
#config: { | |
title: string, | |
max: number, | |
min: number, | |
} = { | |
title: 'ADET', | |
max: 10, | |
min: 1, |
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
fpsMeter() { | |
let prevTime = Date.now(), | |
frames = 0; | |
requestAnimationFrame(function loop() { | |
const time = Date.now(); | |
frames++; | |
if (time > prevTime + 1000) { | |
let fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) ); | |
prevTime = time; |