From 75bd37cc8a61ddfc755d382bb4e2fb35df3134dd Mon Sep 17 00:00:00 2001 From: Sh031224 <1cktmdgh2@gmail.com> Date: Thu, 11 Mar 2021 14:19:08 +0900 Subject: [PATCH] Fix: Type update --- dist/index.d.ts | 20 +++-------- dist/index.js | 47 ++++++------------------- dist/type.d.ts | 14 ++++++++ dist/type.js | 2 ++ src/index.ts | 91 +++++++++++-------------------------------------- src/type.ts | 15 ++++++++ 6 files changed, 64 insertions(+), 125 deletions(-) create mode 100644 dist/type.d.ts create mode 100644 dist/type.js create mode 100644 src/type.ts diff --git a/dist/index.d.ts b/dist/index.d.ts index 349f974..b2beec3 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,16 +1,4 @@ -export declare type TimeCountingDate = string | number | Date; -export interface TimeCountingOption { - objectTime?: string | number | Date; - lang?: "ko" | "en"; - calculate?: { - justNow?: number; - second?: number; - minute?: number; - hour?: number; - day?: number; - week?: number; - month?: number; - }; -} -declare const _default: (time: TimeCountingDate, option?: TimeCountingOption | undefined) => string; -export default _default; +import { TimeCountingDate, TimeCountingOption } from "./type"; +declare const TimeCounting: (time: TimeCountingDate, option?: TimeCountingOption | undefined) => string; +export default TimeCounting; +export { TimeCountingOption, TimeCountingDate }; diff --git a/dist/index.js b/dist/index.js index 48aaa1e..ba1cb53 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = (function (time, option) { +var TimeCounting = function (time, option) { var date = new Date(time); var today = new Date(); var lang = "en"; @@ -70,65 +70,37 @@ exports.default = (function (time, option) { } else if (calc < calculate.second * 1000) { var time_1 = Math.floor(calc / 1000); - var msg = lang === "en" && time_1 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_1 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_1 + message.second + msg; } else if (calc < 60 * calculate.minute * 1000) { var time_2 = Math.floor(calc / 1000 / 60); - var msg = lang === "en" && time_2 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_2 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_2 + message.minute + msg; } else if (calc < 60 * 60 * calculate.hour * 1000) { var time_3 = Math.floor(calc / 1000 / 60 / 60); - var msg = lang === "en" && time_3 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_3 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_3 + message.hour + msg; } else if (calc < 60 * 60 * 24 * calculate.day * 1000) { var time_4 = Math.floor(calc / 1000 / 60 / 60 / 24); - var msg = lang === "en" && time_4 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_4 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_4 + message.day + msg; } else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) { var time_5 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7); - var msg = lang === "en" && time_5 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_5 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_5 + message.week + msg; } else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) { var time_6 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4); - var msg = lang === "en" && time_6 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_6 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_6 + message.month + msg; } else { var time_7 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12); - var msg = lang === "en" && time_7 > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + var msg = lang === "en" && time_7 > 1 ? "s after" : lang === "en" ? " after" : " 후"; return "" + time_7 + message.year + msg; } } @@ -173,4 +145,5 @@ exports.default = (function (time, option) { return "" + time_14 + message.year + msg; } } -}); +}; +exports.default = TimeCounting; diff --git a/dist/type.d.ts b/dist/type.d.ts new file mode 100644 index 0000000..703b9db --- /dev/null +++ b/dist/type.d.ts @@ -0,0 +1,14 @@ +export declare type TimeCountingDate = string | number | Date; +export interface TimeCountingOption { + objectTime?: string | number | Date; + lang?: "ko" | "en"; + calculate?: { + justNow?: number; + second?: number; + minute?: number; + hour?: number; + day?: number; + week?: number; + month?: number; + }; +} diff --git a/dist/type.js b/dist/type.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/type.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/src/index.ts b/src/index.ts index 6735363..4f3997d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,20 +1,6 @@ -export type TimeCountingDate = string | number | Date; - -export interface TimeCountingOption { - objectTime?: string | number | Date; - lang?: "ko" | "en"; - calculate?: { - justNow?: number; - second?: number; - minute?: number; - hour?: number; - day?: number; - week?: number; - month?: number; - }; -} +import { TimeCountingDate, TimeCountingOption } from "./type"; -export default (time: TimeCountingDate, option?: TimeCountingOption) => { +const TimeCounting = (time: TimeCountingDate, option?: TimeCountingOption) => { const date: Date = new Date(time); let today = new Date(); @@ -81,72 +67,37 @@ export default (time: TimeCountingDate, option?: TimeCountingOption) => { return `${message.justNow}${msg}`; } else if (calc < calculate.second * 1000) { const time = Math.floor(calc / 1000); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.second}${msg}`; } else if (calc < 60 * calculate.minute * 1000) { const time = Math.floor(calc / 1000 / 60); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.minute}${msg}`; } else if (calc < 60 * 60 * calculate.hour * 1000) { const time = Math.floor(calc / 1000 / 60 / 60); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.hour}${msg}`; } else if (calc < 60 * 60 * 24 * calculate.day * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.day}${msg}`; } else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.week}${msg}`; } else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.month}${msg}`; } else { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12); - const msg = - lang === "en" && time > 1 - ? "s after" - : lang === "en" - ? " after" - : " 후"; + const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후"; return `${time}${message.year}${msg}`; } @@ -157,46 +108,42 @@ export default (time: TimeCountingDate, option?: TimeCountingOption) => { return `${message.justNow}${msg}`; } else if (calc < calculate.second * 1000) { const time = Math.floor(calc / 1000); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.second}${msg}`; } else if (calc < 60 * calculate.minute * 1000) { const time = Math.floor(calc / 1000 / 60); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.minute}${msg}`; } else if (calc < 60 * 60 * calculate.hour * 1000) { const time = Math.floor(calc / 1000 / 60 / 60); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.hour}${msg}`; } else if (calc < 60 * 60 * 24 * calculate.day * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.day}${msg}`; } else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.week}${msg}`; } else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.month}${msg}`; } else { const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12); - const msg = - lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; + const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전"; return `${time}${message.year}${msg}`; } } }; + +export default TimeCounting; +export { TimeCountingOption, TimeCountingDate }; diff --git a/src/type.ts b/src/type.ts new file mode 100644 index 0000000..b0a8c9f --- /dev/null +++ b/src/type.ts @@ -0,0 +1,15 @@ +export type TimeCountingDate = string | number | Date; + +export interface TimeCountingOption { + objectTime?: string | number | Date; + lang?: "ko" | "en"; + calculate?: { + justNow?: number; + second?: number; + minute?: number; + hour?: number; + day?: number; + week?: number; + month?: number; + }; +}