Skip to content

Instantly share code, notes, and snippets.

View bigsaigon333's full-sized avatar
๐Ÿ‹๏ธ

๊น€๋™ํฌ bigsaigon333

๐Ÿ‹๏ธ
View GitHub Profile
@bigsaigon333
bigsaigon333 / objectStringify.js
Created April 17, 2021 16:26
Code Spitz JS Study 89ํšŒ 4/8ํšŒ์ฐจ ๊ณผ์ œ ์ œ์ถœ - ๊น€๋™ํฌ(Donghee Kim)
// 0. ๊ณตํ†ต๋ชจ๋“ˆ
const EMPTY = {};
const err = message => { throw new Error(message); };
const validateObj = (obj) => {
if (typeof obj !== 'object') err(`Invalid type: ${String(obj)} ${typeof obj}`);
};
@bigsaigon333
bigsaigon333 / useInterval.test.ts
Created August 19, 2021 10:49
useInterval hook ํ…Œ์ŠคํŠธํ•˜๊ธฐ
import { renderHook } from "@testing-library/react-hooks/dom";
import useInterval from "./useInterval";
jest.useFakeTimers();
jest.spyOn(globalThis, "setInterval");
jest.spyOn(globalThis, "clearInterval");
afterEach(() => {
jest.clearAllMocks();
});
@bigsaigon333
bigsaigon333 / List.js
Last active October 7, 2021 08:10
Array.prototype.{map, reduce, join} ์— ์ฐฉ์•ˆํ•œ ์„ ์–ธ์  ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ ๋งŒ๋“ค๊ธฐ
const arr = [
{ id: 1, text: "abc" },
{ id: 2, text: "def" },
{ id: 3, text: "ghi" },
];
const Map = ({ list, children }) => <>{list.map((el) => children(el))}</>;
const Join = ({ separator, children }) => {
// const [Frag] = React.Children.toArray(children);
@bigsaigon333
bigsaigon333 / Calc_๊ณผ์ œ1,2,3.kt
Last active June 6, 2022 05:47
์ฝ”๋“œ์Šคํ”ผ์ธ  90ํšŒ์ฐจ 1๊ฐ• ๊ณผ์ œ
import java.util.*
val trim = """[^.\d-+*()/]""".toRegex()
fun trim(v: String): String = v.replace(trim, "")
val MtoPM = """(?<!^|[*/(])-""".toRegex()
fun repMtoPM(v: String): String = v.replace(MtoPM, "+-")