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
| // ์ฝ๋๊ฐ nodeํ๊ฒฝ์์ ์คํ์ค์ธ์ง ํ์ธ | |
| const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null; | |
| // ๋ธ๋ผ์ฐ์ ์์ ์ฝ๋๊ฐ ์คํ ์ค์ธ์ง ํ์ธ | |
| const isBrowser = typeof window === 'object' && typeof document === 'object'; | |
| // ์ญ์จ๋ฅผ ํ์จ๋ก ๋ณํ | |
| const celsiusToFahrenheit = celsius => celsius * 9/5 + 32; | |
| // ํ์จ๋ฅผ ์ญ์จ๋ก ๋ณํ |
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 isFunction = v => [ | |
| '[object Function]', | |
| '[object GeneratorFunction]', | |
| '[object AsyncFunction]', | |
| '[object Promise]' | |
| ].includes(Object.prototype.toString.call(v)); | |
| // ๊ฐ์ด ์ ๋๋ ์ดํฐ ํจ์์ธ์ง ํ์ธ | |
| const isGeneratorFunction = v => Object.prototype.toString.call(v) === '[object GeneratorFunction]'; |
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 isDescendant = (child, parent) => parent.contains(child); | |
| const div = document.createElement('div') | |
| const h1 = document.createElement('h1') | |
| div.append(h1) | |
| isDescendant(h1, div) | |
| // ์์๊ฐ ํ์ฑํ๋์ด ์๋์ง ํ์ธ | |
| const hasFocus = ele => (ele === document.activeElement); |
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 diffDays = (d1, d2) => Math.ceil(Math.abs(d1 - d2) / (60*60*24*1000)); | |
| // ๋ ๋ ์ง ๋น๊ต | |
| const compare = (a, b) => a.getTime() > b.getTime(); | |
| // ๋ ์ง๋ฅผ yyyy mm dd ํ์์ผ๋ก ๋ณํ | |
| const formatYmd = date => date.toISOString().slice(0, 10); | |
| // ์ด๋ฅผ hh mm ss ํ์์ผ๋ก ๋ณํ |
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 isPlainObject = v => !!v && typeof v === 'object' && (v.__proto__ === null || v.__proto__ === Object.prototype); | |
| const isPlainObject = obj => !!obj && obj.constructor === Object | |
| // ๊ฐ์ด ๊ฐ์ฒด์ธ์ง ํ์ธ | |
| const isObject = v => !!v && typeof v === 'object'; | |
| // ๊ฐ์ฒด๊ฐ ๋น์ด ์๋์ง ํ์ธ | |
| const isEmpty = obj => !!obj && obj.constructor === Object && Reflect.ownKeys(obj).length === 0; | |
| const isEmpty = obj => JSON.stringify(obj) === '{}'; |
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 isEqual = (arr, value) => arr.every(item => item === value); | |
| // ๋ฐฐ์ด์ ๋ชจ๋ ํญ๋ชฉ์ด ๊ฐ์์ง ํ์ธ | |
| const areEqual = arr => arr.every(item => item === arr[0]); | |
| const areEqual = arr => new Set(arr).size === 1; | |
| // ๋ฐฐ์ด์ ์ผ๋ถ ๊ธฐ์ค๊ณผ ์ผ์นํ๋ ๊ฐ์ด ํฌํจ๋์ด ์๋์ง ํ์ธ | |
| const contains = (arr, predicate) => !!arr.find(predicate); | |
| const contains = (arr, predicate) => arr.some(criteria); |
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
| # Fig pre block. Keep at the top of this file. | |
| [[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && . "$HOME/.fig/shell/zshrc.pre.zsh" | |
| # ------------------------------------------------------------------- | |
| # PATH | |
| # ------------------------------------------------------------------- | |
| # oh-my-zs # | |
| export ZSH=$HOME/.oh-my-zsh | |
| # MongoDB # |
NewerOlder