Codewatch is a watch theme that does not collect or store personal information. If you have any related questions, please contact us in the email below. pm2@kakao.com
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 list = [{ text: "a" }, { text: "b" }, { text: "c" }, { text: "d" }]; | |
| // Map & Filter | |
| const i1 = list | |
| .map((item, index) => (item.text === "c" ? index : null)) | |
| .filter((item) => item !== null)[0]!; | |
| // For | |
| let i2 = 0; | |
| for (const item of list) { |
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 Router from 'next/router' | |
| import { useEffect } from 'react' | |
| export default function StaticRoute() { | |
| useEffect(() => { | |
| Router.replace(window.location.pathname, window.location.pathname, { | |
| shallow: true | |
| }) | |
| }, []) | |
| return null |
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
| /** | |
| * Converts an ArrayBuffer to a String. | |
| * | |
| * @param buffer - Buffer to convert. | |
| * @returns String. | |
| */ | |
| export const arrayBufferToString = (buffer: ArrayBuffer) => | |
| String.fromCharCode.apply(null, Array.from(new Uint16Array(buffer))) | |
| /** |
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
| type FileCallbackType = ( | |
| event: | |
| | { | |
| file: File | |
| thumbnail: string | ArrayBuffer | null | |
| getFormData: (name: string) => FormData | |
| }[] | |
| | void | |
| ) => unknown |
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 interface PackNode { | |
| w: number | |
| h: number | |
| x?: number | |
| y?: number | |
| used?: boolean | |
| right?: PackNode | |
| down?: PackNode | |
| fit?: PackNode | |
| } |
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 url = `/component.js`; | |
| const a = document.createElement("a"); | |
| a.href = url; | |
| a.download = url.split("/").pop()!; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); |
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
| // ts | |
| const mod = (n: number, m: number) => { | |
| let r = n % m; | |
| return Math.floor(r >= 0 ? r : r + m); | |
| }; | |
| // js | |
| const mod = (n, m) => { | |
| let r = n % m; | |
| return Math.floor(r >= 0 ? r : r + m); |
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 Excel = require("exceljs"); | |
| const workbook = new Excel.Workbook(); | |
| void (async () => { | |
| const excel = await workbook.xlsx.readFile("before.xlsx"); | |
| const worksheets = excel.worksheets; | |
| // ์ฒซ ๋ฒ์งธ ์ํธ์ ๋ณด ์ป์ด์ค๊ธฐ | |
| const originSheet = worksheets[0]; |
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 outerLexicalEnvironment = { | |
| window: {}, | |
| global: {}, | |
| Object: {}, | |
| Function: {}, | |
| self: {}, | |
| globalThis: {}, | |
| Error: {}, | |
| TypeError: {}, | |
| JSON: {}, |