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
| // ref: https://stackoverflow.com/a/53527984/14491361 | |
| /** | |
| * Scrolls the page automatically until either the end of the page | |
| * @param page - The page to scroll. | |
| * @returns A Promise that resolves when the scrolling is complete. | |
| */ | |
| async function autoScroll(page: Page): Promise<void> { | |
| await page.evaluate(async () => { | |
| await new Promise<void>((resolve) => { |
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
| import { useCallback, useEffect, useState } from 'react'; | |
| const useLocalStorage = (key, initialValue) => { | |
| const [state, setState] = useState(null); | |
| useEffect(() => { | |
| const initialize = (key) => { | |
| try { | |
| const item = localStorage.getItem(key); | |
| if (item && item !== 'undefined') { |
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 root = { | |
| a: { | |
| m: { c: { x: 'apple', y: {} } }, | |
| n: { 1: {}, 2: {} }, | |
| o: {}, | |
| }, | |
| }; | |
| const findPath = (tree, destination) => { | |
| for (let key in tree) { |
NewerOlder