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
| // # Common Module | |
| const createReducer = (initialState, reducer) => (state = initialState, action) => { | |
| return Reflect.has(reducer, action.type) | |
| ? reducer[action.type](state) | |
| : state; | |
| } | |
| // # Usages | |
| // ## before | |
| const initialState = 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
| /** | |
| * ๋ก์ปฌ ํ์์กด ๊ตฌํ๊ธฐ | |
| */ | |
| export const getLocaleTimezone = () => new Date().getTimezoneOffset() / -60; | |
| /** | |
| * Timezone์ ๊ธฐ์ค์ผ๋ก ๋๊ฒจ๋ฐ์ ๋ ์ง๋ฅผ ์ค์ ํ์ฌ ๊ทธ Date์ UTC ์ถ์ถํ๊ธฐ | |
| * @param timezone (-12 ~ +12) | |
| * @param date | |
| */ |
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
| // ์ซ์ํ๋ณํ 2์ง์, 10์ง์, 8์ง์ 16์ง์ | |
| // https://unikys.tistory.com/334 | |
| // 10์ง์๊ฐ ์ฃผ์ด์ง๊ณ ๋ค๋ฅธํ ๋ณํ => source.toString(2 or 8 or 16) | |
| // ๋ค๋ฅธํ์ด ์ฃผ์ด์ง๊ณ 10์ง์ ๋ณํ => parseInt(source, 2 or 8 or 16) | |
| // ๋ ๋ณ์ ์ค์ | |
| let a = 1; | |
| let b = 2; | |
| // solution.1 |
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 { | |
| isPlainObject, | |
| isArray, | |
| isEmpty, | |
| mapKeys, | |
| mapValues, | |
| cloneDeep, | |
| snakeCase, | |
| camelCase, | |
| kebabCase, |
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
| class Custom { | |
| constructor() { | |
| console.log(this.constructor) // [Function: Custom] | |
| console.log(this.constructor.prototype) // Custom {} | |
| console.log(new.target === this.constructor) // true | |
| console.log(new.target.prototype === this.constructor.prototype) // true | |
| } | |
| } | |
| const custom = new Custom() |
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 {Component, Prop, Watch} from 'vue-property-decorator'; | |
| import {BaseComponent} from 'seed/src/BaseComponent'; | |
| import {range} from 'lodash'; | |
| import {lazyInject} from 'seed/src/application-container/ApplicationContext'; | |
| import DependencyInjectId from '@/const/DependencyInjectId'; | |
| import ArticleCheckListService from '@/service/check-list/ArticleCheckListService'; | |
| import {StoveLogService} from 'seed/src/service/logger/StoveLogService'; | |
| import {LogActionType} from 'seed/src/enum/log/LogActionType'; | |
| const intValidator = (value: number) => value > 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 isBetween = (date, min, max) => (date.getTime() >= min.getTime() && date.getTime() <= max.getTime()); | |
| // ๋ ์ง๊ฐ ์ค๋์ธ์ง ํ์ธ | |
| const isToday = (date) => date.toISOString().slice(0, 10) === new Date().toISOString().slice(0, 10); | |
| // ์ฃผ์ด์ง ์ซ์๊ฐ ์์์ธ์ง ํ์ธ | |
| const isPrime = num => (num > 1) && Array(Math.floor(Math.sqrt(num)) - 1).fill(0).map((_, i) => i + 2).every(i => num % i !== 0); | |
| // ์ซ์๊ฐ 2์ ๊ฑฐ๋ญ ์ ๊ณฑ์ธ์ง ํ์ธ |
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 toUpper = string => string.toUpperCase(); | |
| // ๋ฌธ์์ด์ ์ฒซ๋ฌธ์๋ฅผ ๋๋ฌธ์๋ก | |
| const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`; | |
| // ๊ฒฝ๋ก๊ฐ ์๋์ ์ธ์ง ํ์ธ | |
| const isRelative = path => !/^([a-z]+:)?[\\/]/i.test(path); | |
| // Examples |
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 randomBoolean = () => Math.random() >= 0.5; | |
| // ์ฃผ์ด์ง ๋ฒ์์์ ์์์ ๋ถ๋ ์์์ ์๋ฅผ ์์ฑ | |
| const randomFloat = (min, max) => Math.random() * (max - min) + min; | |
| // ์์์ 16 ์ง์ ์์ ์์ฑ | |
| const randomColor = () => `#${Math.random().toString(16).slice(2, 8).padEnd(6, '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 addOrdinal = n => `${n}${['st', 'nd', 'rd'][((n + 90) % 100 - 10) % 10 - 1] || 'th'}`; | |
| const addOrdinal = n => `${n}${[, 'st', 'nd', 'rd'][/1?.$/.exec(n)] || 'th'}`; | |
| const addOrdinal = n => `${n}${[, 'st', 'nd', 'rd'][n % 100 >> 3^1 && n % 10] || 'th'}`; | |
| const addOrdinal = n => `${n}${{one: 'st', two: 'nd', few: 'rd', other: 'th'}[new Intl.PluralRules('en', { type: 'ordinal' }).select(n)]}`; | |
| // Examples | |
| addOrdinal(1); // '1st' | |
| addOrdinal(2); // '2nd' | |
| addOrdinal(3); // '3rd' |
NewerOlder