As Is
ms ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐ๋ ค๋๋ฐ config๋ชจ๋๋ก ๊ฐ์ ธ์ค๋ ๊ฐ ๊ฐ์ ๊ฒฝ์ฐ typescript ๋ ํธํ์ด ์ ์๋๊ณ , common js ์ํฌํธ ๊ด๋ จ ๋ฌธ์ ๊ฐ ๋ฐ์ํจ.
To be
๊ด์ฐฎ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐพ์๋ณด๋๋ฐ ๋ฑํ ์๋ ๊ฒ ๊ฐ์์ ์ ํธ ํด๋์ ๋ฐ๋ก ๋นผ์ ๋ฉ์๋ ๊ตฌํํจ.
GitHub - HenrikJoreteg/milliseconds: Insanely lightweight module for converting times to milliseconds.
Insanely lightweight module for converting times to milliseconds. - GitHub - HenrikJoreteg/milliseconds: Insanely lightweight module for converting times to milliseconds.
github.com
ํด๋น ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐธ๊ณ ํด์ ๋ง๋ฌ.
export const ms = {
seconds(time: number) {
return Math.round(time * 1e3);
},
minutes(time: number) {
return Math.round(time * 6e4);
},
hours(time: number) {
return Math.round(time * 36e5);
},
days(time: number) {
return Math.round(time * 864e5);
},
weeks(time: number) {
return Math.round(time * 6048e5);
},
months(time: number) {
return Math.round(time * 26298e5);
},
years(time: number) {
return Math.round(time * 315576e5);
},
};
ms.days() // ์ด๋ฐ์์ผ๋ก ์ฌ์ฉํ๋ฉด ๋๋ค.
์ค์์น ๋ฌธ ์จ๋ ๋ ๊ฒ ๊ฐ๊ธดํ๋ฐ ์ ๋นํ ์ ๋์๊ฐ