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
| // assuming el is dom object | |
| function checkVisible(el) | |
| { | |
| return el.offsetTop < window.innerHeight + 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
| const quickSort = list => { | |
| if (list.length < 2) | |
| return list; | |
| let pivot = list[0]; | |
| let left = []; | |
| let right = []; | |
| for (let i = 1, total = list.length; i < total; i++){ | |
| if (list[i] < pivot) | |
| left.push(list[i]); | |
| else |
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
| /(.*?)/g | |
| // (.*?) is ungreedy |
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 React, { useMemo, createContext, useRef, useEffect, useState, useContext } from "react"; | |
| function useLoadGsiScript(options = {}) { | |
| const { nonce, onScriptLoadSuccess, onScriptLoadError } = options; | |
| const [scriptLoadedSuccessfully, setScriptLoadedSuccessfully] = useState(false); | |
| const onScriptLoadSuccessRef = useRef(onScriptLoadSuccess); | |
| onScriptLoadSuccessRef.current = onScriptLoadSuccess; | |
| const onScriptLoadErrorRef = useRef(onScriptLoadError); | |
| onScriptLoadErrorRef.current = onScriptLoadError; | |
| useEffect(() => { | |
| const scriptTag = document.createElement("script"); |
OlderNewer