This file contains 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
type Fn = (...args) => any; | |
function debounce(fn: Fn, delay: number = 200) { | |
let timer: NodeJS.Timeout = null; | |
return ((...args) => { | |
if (timer) { | |
clearTimeout(timer); | |
timer = null; | |
} |
This file contains 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
app.get('/movie', async (req, res) => { | |
const { id } = req.query; | |
const movie: MoviePayload = await getMovieById(id); | |
res.json(movie); | |
}); |
This file contains 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 Movie { | |
title: string; | |
} | |
interface Director { | |
name: string; | |
age: number; | |
} | |
interface Actor { |
This file contains 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 Like = () => { | |
const [likes, setLikes] = useState(0); | |
const [dislikes, setDislikes] = useState(0); | |
const onClickLikes = () => setLikes(likes + 1); | |
const onClickDislikes = () => setDislikes(dislikes + 1); | |
return ( | |
<div className="like"> | |
<Avatar |
This file contains 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 MyPage() { | |
const [myInfo, setMyInfo] = useState(null); | |
const [billHistory, setBillHistory] = useState([]); | |
const [friendsList, setFriendsList] = useState([]); | |
useEffect(() => { | |
fetchMyInfo().then(async (mInfo) => { | |
setMyInfo(mInfo); | |
const bHistory = await fetchBillHistory(); |
This file contains 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 MyPage() { | |
const [myInfo, setMyInfo] = useState(null); | |
const [billHistory, setBillHistory] = useState([]); | |
const [friendsList, setFriendsList] = useState([]); | |
useEffect(() => { | |
(async () => { | |
const mInfo = await fetchMyInfo(); | |
const bHistory = await fetchBillHistory(); | |
const fList = await fetchFriendsList(); |
This file contains 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
goto(“/”); | |
login() | |
.then(() => { | |
changeUIComponents(); | |
return updateProfile(); | |
}) | |
.then(() => { | |
reloadPage(); | |
}); |
This file contains 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
goto("/"); | |
await login(); | |
changeUIComponents(); | |
await updateProfile(); | |
reloadPage(); |
This file contains 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
class Queue { | |
pos = -1; | |
queue = []; | |
empty() { | |
while (this.pos > -1) { | |
this.pop(); | |
} | |
} |
This file contains 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 add5(x) { | |
return x + 5; | |
} | |
function mul10(x) { | |
return x * 10; | |
} | |
function pipe(...fn) { | |
return function(v) { |
NewerOlder