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
| // --- Constants --- | |
| const INSTAGRAM_URL = "https://www.instagram.com"; | |
| const IG_APP_ID = "936619743392459"; | |
| const fetchOptions = { | |
| credentials: "include", | |
| headers: { "X-IG-App-ID": IG_APP_ID }, | |
| method: "GET", | |
| }; |
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 will wait until needed time but will block your eventloop | |
| function sleep(time = 0) { | |
| const wakeUpTime = Date.now() + time | |
| while (Date.now() < wakeUpTime) {} | |
| } |
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 sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) |
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
| interface Timer { | |
| name: string; | |
| delay: number; | |
| interval: boolean; | |
| cb: Function; | |
| } | |
| interface TimerForCalling { | |
| name: string; | |
| interval: boolean; |
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 timerId = setTimeout(function tick() { | |
| timerId = setTimeout(tick, 2000) // here you can pass any timeout and dynamically change next calls | |
| }, 1000); | |
| // Example | |
| let call = 1; | |
| let timerId = setTimeout(function tick() { | |
| timerId = setTimeout(tick, 2000 * call); | |
| call++; |
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 makeDeepClone = (obj) => { | |
| let newObject = {}; | |
| Object.keys(obj).map(key => { | |
| if(typeof obj[key] === 'object'){ | |
| newObject[key] = makeDeepClone(obj[key]); | |
| } else { | |
| newObject[key] = obj[key]; | |
| } | |
| }); |