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
| { | |
| "blocks": [ | |
| { | |
| "id": 1, | |
| "doorNumber": "5", | |
| "floorNumber": 11, | |
| "blockNumber": "D2", | |
| "apartmentType": "5+1", | |
| "size": 117, | |
| "fullName": "Tunç Okumuş", |
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 class ImmutableUtility<T> { | |
| #draft: any | |
| constructor(array: Array<T>) { | |
| if (array.length === 0) { | |
| throw new Error('Out of bounds...') | |
| } | |
| this.#draft = [...array] | |
| } |
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 function removeItem<T>(array: Array<T>) { | |
| let cache = array | |
| let count = array.length | |
| let checkArrayContains = (() => Object.is(cache[0], cache[count - 1]))() | |
| let findCurrentIndex = (key: any) => cache.findIndex((item: any) => item === key) | |
| let immutableSlice = (start: number) => [...cache.slice(0, start), ...cache.slice(start + 1)] | |
| if (!Array.isArray(cache)) throw new Error('type error! [array] expected!') |
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 function count( | |
| str: string, | |
| { | |
| trim, | |
| strict, | |
| custom, | |
| }: { | |
| trim?: boolean | |
| strict?: boolean | |
| custom?: RegExp |
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
| /** | |
| Compares two items (values or references) for nested equivalency, meaning that | |
| at root and at each key or index they are equivalent as follows: | |
| - If a value type, values are either hard equal (===) or are both NaN | |
| (different than JS where NaN !== NaN) | |
| - If functions, they are the same function instance or have the same value | |
| when converted to string via `toString()` | |
| - If Date objects, both have the same getTime() or are both NaN (invalid) | |
| - If arrays, both are same length, and all contained values areEquivalent |
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
| function promiseMap(inputValues, mapper) { | |
| const reducer = (acc$, inputValue) => | |
| acc$.then(acc => mapper(inputValue).then(result => acc.push(result) && acc)); | |
| return inputValues.reduce(reducer, Promise.resolve([])); | |
| } | |
| /* Example */ | |
| const axios = require('axios'); |
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; |
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
| /** | |
| * @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
| // Long Polling | |
| let ID = 1 | |
| const foo = document.createElement('p') | |
| async function timeout (callback, delay) { | |
| return await setTimeout(callback, delay) | |
| } | |
| function polling () { | |
| return timeout(() => { |
NewerOlder