@simplysm/sd-core-common
Advanced tools
Comparing version 3.1.124 to 3.1.133
1482
dist/index.js
@@ -1,1463 +0,23 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else { | ||
var a = factory(); | ||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||
} | ||
})(global, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 10); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __webpack_require__(1); | ||
class ArgumentError extends CustomError_1.CustomError { | ||
constructor(argObj) { | ||
super("인수가 잘못되었습니다: " + JSON.stringify(argObj)); | ||
} | ||
} | ||
exports.ArgumentError = ArgumentError; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class CustomError extends Error { | ||
constructor(arg1, arg2) { | ||
if (arg1 instanceof Error || typeof arg2 === "string") { | ||
super(arg2 + (arg1 instanceof Error ? ` => ${arg1.message}` : "")); | ||
} | ||
else { | ||
super(arg1); | ||
} | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = new.target.name; | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, new.target); | ||
} | ||
else { | ||
try { | ||
throw new Error(this.message); | ||
} | ||
catch (err) { | ||
this.stack = err.stack; | ||
} | ||
} | ||
if (arg1 instanceof Error && arg1.stack) { | ||
this.stack += "\n-- inner error stack --\n" + arg1.stack; | ||
} | ||
} | ||
} | ||
exports.CustomError = CustomError; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DateTime_1 = __webpack_require__(3); | ||
const DateOnly_1 = __webpack_require__(5); | ||
const Time_1 = __webpack_require__(6); | ||
const Uuid_1 = __webpack_require__(7); | ||
class ObjectUtil { | ||
static clone(source, options) { | ||
return ObjectUtil._clone(source, options); | ||
} | ||
static _clone(source, options, prevClones) { | ||
var _a, _b, _c, _d; | ||
if (source == undefined) { | ||
return undefined; | ||
} | ||
if (source instanceof Array) { | ||
return source.map((item) => options ? ObjectUtil._clone(item, options) : ObjectUtil._clone(item)); | ||
} | ||
if (source instanceof Date) { | ||
return new Date(source.getTime()); | ||
} | ||
if (source instanceof DateTime_1.DateTime) { | ||
return new DateTime_1.DateTime(source.tick); | ||
} | ||
if (source instanceof DateOnly_1.DateOnly) { | ||
return new DateOnly_1.DateOnly(source.tick); | ||
} | ||
if (source instanceof Time_1.Time) { | ||
return new Time_1.Time(source.tick); | ||
} | ||
if (source instanceof Uuid_1.Uuid) { | ||
return new Uuid_1.Uuid(source.toString()); | ||
} | ||
if (typeof source === "object") { | ||
const result = {}; | ||
Object.setPrototypeOf(result, source["constructor"].prototype); | ||
const currPrevClones = (prevClones !== null && prevClones !== void 0 ? prevClones : []); | ||
currPrevClones.push({ source, clone: result }); | ||
for (const key of Object.keys(source).filter((sourceKey) => { var _a, _b; return !((_b = (_a = options) === null || _a === void 0 ? void 0 : _a.excludes) === null || _b === void 0 ? void 0 : _b.includes(sourceKey)); })) { | ||
if (source[key] == undefined) { | ||
result[key] = undefined; | ||
} | ||
else if ((_b = (_a = options) === null || _a === void 0 ? void 0 : _a.useRefTypes) === null || _b === void 0 ? void 0 : _b.includes(source[key].constructor)) { | ||
result[key] = source[key]; | ||
} | ||
else { | ||
const matchedPrevClone = (_c = prevClones) === null || _c === void 0 ? void 0 : _c.single((item) => item.source === source[key]); | ||
if (matchedPrevClone) { | ||
result[key] = matchedPrevClone.clone; | ||
} | ||
else { | ||
result[key] = ObjectUtil._clone(source[key], { useRefTypes: (_d = options) === null || _d === void 0 ? void 0 : _d.useRefTypes }, currPrevClones); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
return source; | ||
} | ||
static merge(source, target) { | ||
if (source === undefined) { | ||
return ObjectUtil.clone(target); | ||
} | ||
if (target === undefined) { | ||
return ObjectUtil.clone(source); | ||
} | ||
if (typeof target !== "object") { | ||
return target; | ||
} | ||
if (target instanceof Date || target instanceof DateTime_1.DateTime || target instanceof DateOnly_1.DateOnly || target instanceof Time_1.Time || target instanceof Uuid_1.Uuid) { | ||
return ObjectUtil.clone(target); | ||
} | ||
if (typeof source !== typeof target) { | ||
throw new Error("병합하려고 하는 두 객체의 타입이 서로 다릅니다."); | ||
} | ||
const result = ObjectUtil.clone(source); | ||
for (const key of Object.keys(target)) { | ||
result[key] = ObjectUtil.merge(source[key], target[key]); | ||
} | ||
return result; | ||
} | ||
static equal(source, target, options) { | ||
var _a, _b; | ||
if (source === target) { | ||
return true; | ||
} | ||
if (source instanceof Date && target instanceof Date) { | ||
return source.getTime() === target.getTime(); | ||
} | ||
if ((source instanceof Time_1.Time && target instanceof DateTime_1.DateTime) || | ||
(source instanceof Time_1.Time && target instanceof DateOnly_1.DateOnly) || | ||
(source instanceof Time_1.Time && target instanceof Time_1.Time)) { | ||
return source.tick === target.tick; | ||
} | ||
if (source instanceof Array && target instanceof Array) { | ||
if (source.length !== target.length) { | ||
return false; | ||
} | ||
if ((_a = options) === null || _a === void 0 ? void 0 : _a.ignoreArrayIndex) { | ||
return source.every((sourceItem) => target.some((targetItem) => ObjectUtil.equal(targetItem, sourceItem, options))); | ||
} | ||
else { | ||
for (let i = 0; i < source.length; i++) { | ||
if (!ObjectUtil.equal(source[i], target[i], options)) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
if (typeof source === "object" && typeof target === "object") { | ||
const sourceKeys = Object.keys(source) | ||
.filter((key) => { var _a, _b, _c, _d; return (!((_a = options) === null || _a === void 0 ? void 0 : _a.keys) || ((_b = options) === null || _b === void 0 ? void 0 : _b.keys.includes(key))) && (!((_d = (_c = options) === null || _c === void 0 ? void 0 : _c.excludes) === null || _d === void 0 ? void 0 : _d.includes(key))) && source[key] !== undefined; }); | ||
const targetKeys = Object.keys(target) | ||
.filter((key) => { var _a, _b, _c, _d; return (!((_a = options) === null || _a === void 0 ? void 0 : _a.keys) || ((_b = options) === null || _b === void 0 ? void 0 : _b.keys.includes(key))) && (!((_d = (_c = options) === null || _c === void 0 ? void 0 : _c.excludes) === null || _d === void 0 ? void 0 : _d.includes(key))) && target[key] !== undefined; }); | ||
if (sourceKeys.length !== targetKeys.length) { | ||
return false; | ||
} | ||
for (const key of sourceKeys) { | ||
if (!ObjectUtil.equal(source[key], target[key], { ignoreArrayIndex: (_b = options) === null || _b === void 0 ? void 0 : _b.ignoreArrayIndex })) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
static validate(value, def) { | ||
let currDef; | ||
if (def instanceof Array) { | ||
currDef = { | ||
type: def | ||
}; | ||
} | ||
else if (typeof def === "function") { | ||
currDef = { | ||
type: [def] | ||
}; | ||
} | ||
else { | ||
currDef = { | ||
...def, | ||
type: def.type ? def.type instanceof Array ? def.type : [def.type] : undefined | ||
}; | ||
} | ||
const invalidateDef = {}; | ||
if (currDef.notnull && value === undefined) { | ||
invalidateDef.notnull = currDef.notnull; | ||
} | ||
if (!currDef.notnull && value === undefined) { | ||
return undefined; | ||
} | ||
if (currDef.type && | ||
!currDef.type.some((type) => { var _a; return type === ((_a = value) === null || _a === void 0 ? void 0 : _a.constructor); })) { | ||
invalidateDef.type = currDef.type; | ||
} | ||
if (currDef.validator && !currDef.validator(value)) { | ||
invalidateDef.validator = currDef.validator; | ||
} | ||
if (currDef.includes && !currDef.includes.includes(value)) { | ||
invalidateDef.includes = currDef.includes; | ||
} | ||
if (Object.keys(invalidateDef).length > 0) { | ||
return { value, invalidateDef }; | ||
} | ||
return undefined; | ||
} | ||
static validateObject(obj, def) { | ||
const result = {}; | ||
for (const defKey of Object.keys(def)) { | ||
const validateResult = ObjectUtil.validate(obj[defKey], def[defKey]); | ||
if (validateResult) { | ||
result[defKey] = validateResult; | ||
} | ||
} | ||
return result; | ||
} | ||
static validateArray(arr, def) { | ||
const result = []; | ||
for (let i = 0; i < arr.length; i++) { | ||
const item = arr[i]; | ||
const validateObjectResult = ObjectUtil.validateObject(item, typeof def === "function" ? def(item) : def); | ||
if (Object.keys(validateObjectResult).length > 0) { | ||
result.push({ | ||
index: i, | ||
item, | ||
result: validateObjectResult | ||
}); | ||
} | ||
} | ||
return result; | ||
} | ||
static getChainValueByDepth(obj, key, depth, optional) { | ||
let result = obj; | ||
for (let i = 0; i < depth; i++) { | ||
if (optional) { | ||
result = result ? result[key] : undefined; | ||
} | ||
else { | ||
result = result[key]; | ||
} | ||
} | ||
return result; | ||
} | ||
static getChainValue(obj, chain, optional) { | ||
const split = chain.split("."); | ||
let result = obj; | ||
for (const splitItem of split) { | ||
if (optional && result === undefined) { | ||
result = undefined; | ||
} | ||
else { | ||
result = result[splitItem]; | ||
} | ||
} | ||
return result; | ||
} | ||
static setChainValue(obj, chain, value) { | ||
const split = chain.split("."); | ||
let curr = obj; | ||
for (const splitItem of split.slice(0, -1)) { | ||
curr = curr[splitItem]; | ||
} | ||
curr[split.last()] = value; | ||
} | ||
static deleteChainValue(obj, chain) { | ||
const split = chain.split("."); | ||
let curr = obj; | ||
for (const splitItem of split.slice(0, -1)) { | ||
curr = curr[splitItem]; | ||
} | ||
delete curr[split.last()]; | ||
} | ||
static clearUndefined(obj) { | ||
if (obj === undefined) { | ||
return obj; | ||
} | ||
for (const key of Object.keys(obj)) { | ||
if (obj[key] === undefined) { | ||
delete obj[key]; | ||
} | ||
} | ||
return obj; | ||
} | ||
} | ||
exports.ObjectUtil = ObjectUtil; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ArgumentError_1 = __webpack_require__(0); | ||
const DateTimeFormatUtil_1 = __webpack_require__(4); | ||
class DateTime { | ||
constructor(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { | ||
if (arg1 === undefined) { | ||
this._date = new Date(); | ||
} | ||
else if (arg2 !== undefined && arg3 !== undefined) { | ||
this._date = new Date(arg1, arg2 - 1, (arg3 !== null && arg3 !== void 0 ? arg3 : 0), (arg4 !== null && arg4 !== void 0 ? arg4 : 0), (arg5 !== null && arg5 !== void 0 ? arg5 : 0), (arg6 !== null && arg6 !== void 0 ? arg6 : 0), (arg7 !== null && arg7 !== void 0 ? arg7 : 0)); | ||
} | ||
else { | ||
this._date = new Date(arg1); | ||
} | ||
} | ||
static parse(str) { | ||
const parsedTick = Date.parse(str); | ||
if (parsedTick && !Number.isNaN(parsedTick)) { | ||
return new DateTime(parsedTick); | ||
} | ||
const match1 = str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2}) (오전|오후) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/); | ||
if (match1) { | ||
return new DateTime(Number(match1[1]), Number(match1[2]), Number(match1[3]), Number(match1[5]) + (match1[4] === "오후" ? 12 : 0), Number(match1[6]), Number(match1[7])); | ||
} | ||
const match2 = str.match(/^[0-9]{14}$/); | ||
if (match2) { | ||
return new DateTime(Number(str.substr(0, 4)), Number(str.substr(4, 2)), Number(str.substr(6, 2)), Number(str.substr(8, 2)), Number(str.substr(10, 2)), Number(str.substr(12, 2))); | ||
} | ||
const match3 = str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{3}))?$/); | ||
if (match3) { | ||
return new DateTime(Number(match3[1]), Number(match3[2]), Number(match3[3]), Number(match3[4]), Number(match3[5]), Number(match3[6]), match3[7] ? Number(match3[8]) : undefined); | ||
} | ||
throw new ArgumentError_1.ArgumentError({ str }); | ||
} | ||
get year() { | ||
return this._date.getFullYear(); | ||
} | ||
set year(value) { | ||
this._date.setFullYear(value); | ||
} | ||
get month() { | ||
return this._date.getMonth() + 1; | ||
} | ||
set month(value) { | ||
this._date.setMonth(value - 1); | ||
} | ||
get day() { | ||
return this._date.getDate(); | ||
} | ||
set day(value) { | ||
this._date.setDate(value); | ||
} | ||
get hour() { | ||
return this._date.getHours(); | ||
} | ||
set hour(value) { | ||
this._date.setHours(value); | ||
} | ||
get minute() { | ||
return this._date.getMinutes(); | ||
} | ||
set minute(value) { | ||
this._date.setMinutes(value); | ||
} | ||
get second() { | ||
return this._date.getSeconds(); | ||
} | ||
set second(value) { | ||
this._date.setSeconds(value); | ||
} | ||
get millisecond() { | ||
return this._date.getMilliseconds(); | ||
} | ||
set millisecond(value) { | ||
this._date.setMilliseconds(value); | ||
} | ||
get tick() { | ||
return this._date.getTime(); | ||
} | ||
set tick(tick) { | ||
this._date.setTime(tick); | ||
} | ||
get week() { | ||
return this._date.getDay(); | ||
} | ||
get timezoneOffsetMinutes() { | ||
return -this._date.getTimezoneOffset(); | ||
} | ||
setYear(year) { | ||
return new DateTime(new Date(this.tick).setFullYear(year)); | ||
} | ||
setMonth(month) { | ||
return new DateTime(new Date(this.tick).setMonth(month - 1)); | ||
} | ||
setDay(day) { | ||
return new DateTime(new Date(this.tick).setDate(day)); | ||
} | ||
setHour(hour) { | ||
return new DateTime(new Date(this.tick).setHours(hour)); | ||
} | ||
setMinute(minute) { | ||
return new DateTime(new Date(this.tick).setMinutes(minute)); | ||
} | ||
setSecond(second) { | ||
return new DateTime(new Date(this.tick).setSeconds(second)); | ||
} | ||
setMillisecond(millisecond) { | ||
return new DateTime(new Date(this.tick).setMilliseconds(millisecond)); | ||
} | ||
addYears(years) { | ||
return this.setYear(this.year + years); | ||
} | ||
addMonths(months) { | ||
return this.setMonth(this.month + months); | ||
} | ||
addDays(days) { | ||
return this.setDay(this.day + days); | ||
} | ||
addHours(hours) { | ||
return this.setHour(this.hour + hours); | ||
} | ||
addMinutes(minutes) { | ||
return this.setMinute(this.minute + minutes); | ||
} | ||
addSeconds(seconds) { | ||
return this.setSecond(this.second + seconds); | ||
} | ||
addMilliseconds(milliseconds) { | ||
return this.setMillisecond(this.millisecond + milliseconds); | ||
} | ||
toFormatString(format) { | ||
return DateTimeFormatUtil_1.DateTimeFormatUtil.format(format, { | ||
year: this.year, | ||
month: this.month, | ||
day: this.day, | ||
hour: this.hour, | ||
minute: this.minute, | ||
second: this.second, | ||
millisecond: this.millisecond, | ||
timezoneOffsetMinutes: this.timezoneOffsetMinutes | ||
}); | ||
} | ||
toString() { | ||
return this.toFormatString("yyyy-MM-ddTHH:mm:ss.fffzzz"); | ||
} | ||
} | ||
exports.DateTime = DateTime; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DateTimeFormatUtil { | ||
static format(format, args) { | ||
const year = args.year; | ||
const month = args.month; | ||
const day = args.day; | ||
const hour = args.hour; | ||
const minute = args.minute; | ||
const second = args.second; | ||
const millisecond = args.millisecond; | ||
const offsetHour = args.timezoneOffsetMinutes !== undefined ? Math.floor(args.timezoneOffsetMinutes / 60) : undefined; | ||
const offsetMinute = args.timezoneOffsetMinutes !== undefined ? args.timezoneOffsetMinutes % 60 : undefined; | ||
const week = (year && month && day) ? new Date(year, month - 1, day).getDay() : undefined; | ||
const weekString = week === 0 ? "일" : | ||
week === 1 ? "월" : | ||
week === 2 ? "화" : | ||
week === 3 ? "수" : | ||
week === 4 ? "목" : | ||
week === 5 ? "금" : | ||
week === 6 ? "토" : | ||
undefined; | ||
let result = format; | ||
if (year !== undefined) { | ||
result = result.replace(/yyyy/g, year.toString()); | ||
result = result.replace(/yy/g, year.toString().substr(2, 2)); | ||
} | ||
if (month !== undefined) { | ||
result = result.replace(/MM/g, month.toString().padStart(2, "0")); | ||
result = result.replace(/M/g, month.toString()); | ||
} | ||
if (weekString !== undefined) { | ||
result = result.replace(/ddd/g, weekString); | ||
} | ||
if (day !== undefined) { | ||
result = result.replace(/dd/g, day.toString().padStart(2, "0")); | ||
result = result.replace(/d/g, day.toString()); | ||
} | ||
if (hour !== undefined) { | ||
result = result.replace(/tt/g, hour < 12 ? "오전" : "오후"); | ||
result = result.replace(/hh/g, (hour % 12).toString().padStart(2, "0")); | ||
result = result.replace(/h/g, (hour % 12).toString()); | ||
result = result.replace(/HH/g, hour.toString().padStart(2, "0")); | ||
result = result.replace(/H/g, hour.toString()); | ||
} | ||
if (minute !== undefined) { | ||
result = result.replace(/mm/g, minute.toString().padStart(2, "0")); | ||
result = result.replace(/m/g, minute.toString()); | ||
} | ||
if (second !== undefined) { | ||
result = result.replace(/ss/g, second.toString().padStart(2, "0")); | ||
result = result.replace(/s/g, second.toString()); | ||
} | ||
if (millisecond !== undefined) { | ||
result = result.replace(/fff/g, millisecond.toString().padStart(3, "0")); | ||
result = result.replace(/ff/g, millisecond.toString().padStart(3, "0").substr(0, 2)); | ||
result = result.replace(/f/g, millisecond.toString().padStart(3, "0").substr(0, 1)); | ||
} | ||
if (offsetHour !== undefined && offsetMinute !== undefined) { | ||
result = result.replace(/zzz/g, (offsetHour > 0 ? "+" : "-") + Math.abs(offsetHour).toString().padStart(2, "0") + ":" + Math.abs(offsetMinute).toString().padStart(2, "0")); | ||
result = result.replace(/zz/g, (offsetHour > 0 ? "+" : "-") + Math.abs(offsetHour).toString().padStart(2, "0")); | ||
result = result.replace(/z/g, (offsetHour > 0 ? "+" : "-") + Math.abs(offsetHour).toString()); | ||
} | ||
return result; | ||
} | ||
} | ||
exports.DateTimeFormatUtil = DateTimeFormatUtil; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ArgumentError_1 = __webpack_require__(0); | ||
const DateTimeFormatUtil_1 = __webpack_require__(4); | ||
class DateOnly { | ||
constructor(arg1, arg2, arg3) { | ||
if (arg1 === undefined) { | ||
const tick = Date.now(); | ||
this._date = new Date(tick - (tick % (24 * 60 * 60 * 1000))); | ||
} | ||
else if (arg2 !== undefined && arg3 !== undefined) { | ||
this._date = new Date(arg1, arg2 - 1, (arg3 !== null && arg3 !== void 0 ? arg3 : 0)); | ||
} | ||
else { | ||
this._date = new Date(arg1 - (arg1 % (24 * 60 * 60 * 1000))); | ||
} | ||
} | ||
static parse(str) { | ||
const parsedTick = Date.parse(str); | ||
if (parsedTick && !Number.isNaN(parsedTick)) { | ||
return new DateOnly(parsedTick); | ||
} | ||
const match1 = str.match(/^[0-9]{8}$/); | ||
if (match1) { | ||
return new DateOnly(Number(str.substr(0, 4)), Number(str.substr(4, 2)), Number(str.substr(6, 2))); | ||
} | ||
throw new ArgumentError_1.ArgumentError({ str }); | ||
} | ||
get year() { | ||
return this._date.getFullYear(); | ||
} | ||
set year(value) { | ||
this._date.setFullYear(value); | ||
} | ||
get month() { | ||
return this._date.getMonth() + 1; | ||
} | ||
set month(value) { | ||
this._date.setMonth(value - 1); | ||
} | ||
get day() { | ||
return this._date.getDate(); | ||
} | ||
set day(value) { | ||
this._date.setDate(value); | ||
} | ||
get tick() { | ||
return this._date.getTime(); | ||
} | ||
set tick(tick) { | ||
this._date.setTime(tick - (tick % (24 * 60 * 60 * 1000))); | ||
} | ||
get week() { | ||
return this._date.getDay(); | ||
} | ||
setYear(year) { | ||
return new DateOnly(new Date(this.tick).setFullYear(year)); | ||
} | ||
setMonth(month) { | ||
return new DateOnly(new Date(this.tick).setMonth(month - 1)); | ||
} | ||
setDay(day) { | ||
return new DateOnly(new Date(this.tick).setDate(day)); | ||
} | ||
addYears(years) { | ||
return this.setYear(this.year + years); | ||
} | ||
addMonths(months) { | ||
return this.setMonth(this.month + months); | ||
} | ||
addDays(days) { | ||
return this.setDay(this.day + days); | ||
} | ||
toFormatString(format) { | ||
return DateTimeFormatUtil_1.DateTimeFormatUtil.format(format, { | ||
year: this.year, | ||
month: this.month, | ||
day: this.day | ||
}); | ||
} | ||
toString() { | ||
return this.toFormatString("yyyy-MM-dd"); | ||
} | ||
} | ||
exports.DateOnly = DateOnly; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ArgumentError_1 = __webpack_require__(0); | ||
const DateTimeFormatUtil_1 = __webpack_require__(4); | ||
class Time { | ||
constructor(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { | ||
if (arg1 === undefined) { | ||
const now = new Date(); | ||
this._tick = (now.getMilliseconds() | ||
+ now.getSeconds() * 1000 | ||
+ now.getMinutes() * 60 * 1000 | ||
+ now.getHours() * 60 * 60 * 1000) % (24 * 60 * 60 * 1000); | ||
} | ||
else if (arg2 !== undefined) { | ||
this._tick = (((arg4 !== null && arg4 !== void 0 ? arg4 : 0)) | ||
+ ((arg3 !== null && arg3 !== void 0 ? arg3 : 0)) * 1000 | ||
+ arg2 * 60 * 1000 | ||
+ arg1 * 60 * 60 * 1000) % (24 * 60 * 60 * 1000); | ||
} | ||
else { | ||
this._tick = arg1 % (24 * 60 * 60 * 1000); | ||
} | ||
} | ||
static parse(str) { | ||
const match1 = str.match(/^(오전|오후) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})(\.([0-9]{1,3}))?$/); | ||
if (match1) { | ||
return new Time(Number(match1[2]) + (match1[1] === "오후" ? 12 : 0), Number(match1[3]), Number(match1[4]), Number(match1[5] ? match1[6].padEnd(3, "0") : "0")); | ||
} | ||
const match2 = str.match(/^([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})(\.([0-9]{1,3}))?$/); | ||
if (match2) { | ||
return new Time(Number(match2[1]), Number(match2[2]), Number(match2[3]), Number(match2[4] ? match2[5].padEnd(3, "0") : "0")); | ||
} | ||
throw new ArgumentError_1.ArgumentError({ str }); | ||
} | ||
get hour() { | ||
return Math.floor(this._tick / (60 * 60 * 1000)); | ||
} | ||
set hour(value) { | ||
this._tick = (this._tick + ((value - this.hour) * 60 * 60 * 1000)) % (24 * 60 * 60 * 1000); | ||
} | ||
get minute() { | ||
return Math.floor(this._tick / (60 * 1000)) % 60; | ||
} | ||
set minute(value) { | ||
this._tick = (this._tick + ((value - this.minute) * 60 * 1000)) % (24 * 60 * 60 * 1000); | ||
} | ||
get second() { | ||
return Math.floor(this._tick / 1000) % 60; | ||
} | ||
set second(value) { | ||
this._tick = (this._tick + ((value - this.second) * 1000)) % (24 * 60 * 60 * 1000); | ||
} | ||
get millisecond() { | ||
return this._tick % 1000; | ||
} | ||
set millisecond(value) { | ||
this._tick = (this._tick + (value - this.millisecond)) % (24 * 60 * 60 * 1000); | ||
} | ||
get tick() { | ||
return this._tick; | ||
} | ||
set tick(tick) { | ||
this._tick = tick % (24 * 60 * 60 * 1000); | ||
} | ||
setHour(hour) { | ||
return new Time(hour, this.minute, this.second, this.millisecond); | ||
} | ||
setMinute(minute) { | ||
return new Time(this.hour, minute, this.second, this.millisecond); | ||
} | ||
setSecond(second) { | ||
return new Time(this.hour, this.minute, second, this.millisecond); | ||
} | ||
setMillisecond(millisecond) { | ||
return new Time(this.hour, this.minute, this.second, millisecond); | ||
} | ||
addHours(hours) { | ||
return this.setHour(this.hour + hours); | ||
} | ||
addMinutes(minutes) { | ||
return this.setMinute(this.minute + minutes); | ||
} | ||
addSeconds(seconds) { | ||
return this.setSecond(this.second + seconds); | ||
} | ||
addMilliseconds(milliseconds) { | ||
return this.setMillisecond(this.millisecond + milliseconds); | ||
} | ||
toFormatString(format) { | ||
return DateTimeFormatUtil_1.DateTimeFormatUtil.format(format, { | ||
hour: this.hour, | ||
minute: this.minute, | ||
second: this.second, | ||
millisecond: this.millisecond | ||
}); | ||
} | ||
toString() { | ||
return this.toFormatString("HH:mm:ss.fff"); | ||
} | ||
} | ||
exports.Time = Time; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Uuid { | ||
constructor(uuid) { | ||
this._uuid = uuid; | ||
} | ||
static new() { | ||
const fn = () => { | ||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { | ||
const r = Math.random() * 16 | 0; | ||
const v = c === "x" ? r : (r & 0x3 | 0x8); | ||
return v.toString(16); | ||
}); | ||
}; | ||
let uuid; | ||
while (true) { | ||
uuid = fn(); | ||
if (!Uuid._prevUuids.some((item) => item._uuid === uuid)) { | ||
break; | ||
} | ||
} | ||
const uuidObj = new Uuid(uuid); | ||
Uuid._prevUuids.push(uuidObj); | ||
return uuidObj; | ||
} | ||
toString() { | ||
return this._uuid; | ||
} | ||
} | ||
exports.Uuid = Uuid; | ||
Uuid._prevUuids = []; | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function PropertyGetSetDecoratorBase(arg) { | ||
return function (target, propertyName, inputDescriptor) { | ||
var _a, _b; | ||
const prevDescriptor = (inputDescriptor !== null && inputDescriptor !== void 0 ? inputDescriptor : Object.getOwnPropertyDescriptor(target, propertyName)); | ||
const prevGetter = (_a = prevDescriptor) === null || _a === void 0 ? void 0 : _a.get; | ||
const prevSetter = (_b = prevDescriptor) === null || _b === void 0 ? void 0 : _b.set; | ||
let _val = target[propertyName]; | ||
const getter = function () { | ||
const value = prevGetter ? prevGetter.bind(this)() : _val; | ||
if (arg.get) { | ||
arg.get(this, propertyName, value); | ||
} | ||
return value; | ||
}; | ||
const setter = function (value) { | ||
const prevValue = prevGetter ? prevGetter.bind(this)() : _val; | ||
let realValue = value; | ||
if (arg.beforeSet) { | ||
const beforeSetResult = arg.beforeSet(this, propertyName, prevValue, realValue); | ||
if (beforeSetResult) { | ||
realValue = beforeSetResult(); | ||
} | ||
} | ||
if (prevSetter) { | ||
prevSetter.bind(this)(realValue); | ||
} | ||
else { | ||
_val = realValue; | ||
} | ||
if (arg.afterSet) { | ||
arg.afterSet(this, propertyName, prevValue, realValue); | ||
} | ||
}; | ||
if (delete target[propertyName]) { | ||
Object.defineProperty(target, propertyName, { | ||
get: getter, | ||
set: setter, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
}; | ||
} | ||
exports.PropertyGetSetDecoratorBase = PropertyGetSetDecoratorBase; | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __webpack_require__(1); | ||
class TimeoutError extends CustomError_1.CustomError { | ||
constructor(millisecond, message) { | ||
super(`대기시간이 초과되었습니다${millisecond ? `(${millisecond}ms)` : ""}${message ? `: ${message}` : ""}`); | ||
} | ||
} | ||
exports.TimeoutError = TimeoutError; | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = __webpack_require__(11); | ||
__webpack_require__(12); | ||
__webpack_require__(13); | ||
tslib_1.__exportStar(__webpack_require__(14), exports); | ||
tslib_1.__exportStar(__webpack_require__(8), exports); | ||
tslib_1.__exportStar(__webpack_require__(15), exports); | ||
tslib_1.__exportStar(__webpack_require__(0), exports); | ||
tslib_1.__exportStar(__webpack_require__(1), exports); | ||
tslib_1.__exportStar(__webpack_require__(16), exports); | ||
tslib_1.__exportStar(__webpack_require__(9), exports); | ||
tslib_1.__exportStar(__webpack_require__(17), exports); | ||
tslib_1.__exportStar(__webpack_require__(5), exports); | ||
tslib_1.__exportStar(__webpack_require__(3), exports); | ||
tslib_1.__exportStar(__webpack_require__(6), exports); | ||
tslib_1.__exportStar(__webpack_require__(7), exports); | ||
tslib_1.__exportStar(__webpack_require__(18), exports); | ||
tslib_1.__exportStar(__webpack_require__(19), exports); | ||
tslib_1.__exportStar(__webpack_require__(20), exports); | ||
tslib_1.__exportStar(__webpack_require__(2), exports); | ||
tslib_1.__exportStar(__webpack_require__(21), exports); | ||
/***/ }), | ||
/* 11 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("tslib"); | ||
/***/ }), | ||
/* 12 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("core-js"); | ||
/***/ }), | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ObjectUtil_1 = __webpack_require__(2); | ||
Array.prototype.single = function (predicate) { | ||
const arr = predicate ? this.filter(predicate.bind(this)) : this; | ||
if (arr.length > 1) { | ||
throw new Error("복수의 결과물이 있습니다."); | ||
} | ||
return arr[0]; | ||
}; | ||
Array.prototype.last = function (predicate) { | ||
if (predicate) { | ||
for (let i = this.length - 1; i >= 0; i--) { | ||
if (predicate(this[i], i)) { | ||
return this[i]; | ||
} | ||
} | ||
return undefined; | ||
} | ||
else { | ||
return this[this.length - 1]; | ||
} | ||
}; | ||
Array.prototype.filterExists = function () { | ||
return this.filter((item) => item !== undefined); | ||
}; | ||
Array.prototype.ofType = function (type) { | ||
return this.filter((item) => { var _a; return item instanceof type || ((_a = item) === null || _a === void 0 ? void 0 : _a.constructor) === type; }); | ||
}; | ||
Array.prototype.mapMany = function (selector) { | ||
const arr = selector ? this.map(selector) : this; | ||
return arr.reduce((p, n) => p.concat(n)); | ||
}; | ||
Array.prototype.mapAsync = async function (selector) { | ||
return await Promise.all(this.map(selector)); | ||
}; | ||
Array.prototype.mapManyAsync = async function (selector) { | ||
const arr = selector ? await this.mapAsync(selector) : this; | ||
return arr.mapMany(); | ||
}; | ||
Array.prototype.parallelAsync = async function (fn) { | ||
await Promise.all(this.map(async (item, index) => { | ||
await fn(item, index); | ||
})); | ||
}; | ||
Array.prototype.groupBy = function (keySelector, valueSelector) { | ||
const result = []; | ||
for (let i = 0; i < this.length; i++) { | ||
const keyObj = keySelector(this[i], i); | ||
const valueObj = valueSelector ? valueSelector(this[i], i) : this[i]; | ||
const existsRecord = result.single((item) => ObjectUtil_1.ObjectUtil.equal(item.key, keyObj)); | ||
if (existsRecord) { | ||
existsRecord.values.push(valueObj); | ||
} | ||
else { | ||
result.push({ key: keyObj, values: [valueObj] }); | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.toMap = function (keySelector, valueSelector) { | ||
const result = new Map(); | ||
for (let i = 0; i < this.length; i++) { | ||
const item = this[i]; | ||
const keyObj = keySelector(item, i); | ||
const valueObj = valueSelector ? valueSelector(item, i) : item; | ||
if (result.has(keyObj)) { | ||
throw new Error(`키가 중복되었습니다. (중복된키: ${JSON.stringify(keyObj)})`); | ||
} | ||
result.set(keyObj, valueObj); | ||
} | ||
return result; | ||
}; | ||
Array.prototype.toObject = function (keySelector, valueSelector) { | ||
const result = {}; | ||
for (let i = 0; i < this.length; i++) { | ||
const item = this[i]; | ||
const key = keySelector(item, i); | ||
const valueObj = valueSelector ? valueSelector(item, i) : item; | ||
if (result[key]) { | ||
throw new Error(`키가 중복되었습니다. (중복된키: ${key})`); | ||
} | ||
result[key] = valueObj; | ||
} | ||
return result; | ||
}; | ||
Array.prototype.distinct = function () { | ||
const result = []; | ||
for (const item of this) { | ||
if (!result.some((item1) => ObjectUtil_1.ObjectUtil.equal(item1, item))) { | ||
result.push(item); | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.orderBy = function (selector) { | ||
return this.concat().sort((p, n) => { | ||
const pn = selector ? selector(n) : n; | ||
const pp = selector ? selector(p) : p; | ||
if ((typeof pn !== "string" && typeof pn !== "number") || | ||
(typeof pp !== "string" && typeof pp !== "number")) { | ||
throw new Error("orderBy 는 string 이나 number 에 대해서만 사용할 수 있습니다."); | ||
} | ||
return (pn > pp ? -1 : pn < pp ? 1 : 0); | ||
}); | ||
}; | ||
Array.prototype.orderByDesc = function (selector) { | ||
return this.concat().sort((p, n) => { | ||
const pn = selector ? selector(n) : n; | ||
const pp = selector ? selector(p) : p; | ||
if ((typeof pn !== "string" && typeof pn !== "number") || | ||
(typeof pp !== "string" && typeof pp !== "number")) { | ||
throw new Error("orderBy 는 string 이나 number 에 대해서만 사용할 수 있습니다."); | ||
} | ||
return (pn < pp ? -1 : pn > pp ? 1 : 0); | ||
}); | ||
}; | ||
Array.prototype.diffs = function (target, options) { | ||
var _a; | ||
const result = []; | ||
const uncheckedTarget = [].concat(target); | ||
for (const sourceItem of this) { | ||
const sameTarget = uncheckedTarget.single((targetItem) => { var _a, _b; return ObjectUtil_1.ObjectUtil.equal(targetItem, sourceItem, ((_a = options) === null || _a === void 0 ? void 0 : _a.excludes) ? { excludes: (_b = options) === null || _b === void 0 ? void 0 : _b.excludes } : undefined); }); | ||
if (!sameTarget) { | ||
if ((_a = options) === null || _a === void 0 ? void 0 : _a.keys) { | ||
const sameKeyTargetItem = uncheckedTarget.single((targetItem) => ObjectUtil_1.ObjectUtil.equal(targetItem, sourceItem, { keys: options.keys })); | ||
if (sameKeyTargetItem) { | ||
result.push({ source: sourceItem, target: sameKeyTargetItem }); | ||
uncheckedTarget.remove(sameKeyTargetItem); | ||
continue; | ||
} | ||
} | ||
result.push({ source: sourceItem }); | ||
} | ||
else { | ||
uncheckedTarget.remove(sameTarget); | ||
} | ||
} | ||
for (const uncheckedTargetItem of uncheckedTarget) { | ||
result.push({ target: uncheckedTargetItem }); | ||
} | ||
return result; | ||
}; | ||
Array.prototype.merge = function (target, options) { | ||
const diffs = this.diffs(target, options); | ||
const result = ObjectUtil_1.ObjectUtil.clone(this); | ||
for (const diff of diffs) { | ||
if (diff.source && diff.target) { | ||
const resultSourceItem = result.single((item) => ObjectUtil_1.ObjectUtil.equal(item, diff.source)); | ||
result[result.indexOf(resultSourceItem)] = ObjectUtil_1.ObjectUtil.merge(diff.source, diff.target); | ||
} | ||
else if (diff.target) { | ||
result.push(diff.target); | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.sum = function (selector) { | ||
let result = 0; | ||
for (let i = 0; i < this.length; i++) { | ||
const item = selector ? selector(this[i], i) : this[i]; | ||
if (typeof item !== "number") { | ||
throw new Error("sum 은 number 에 대해서만 사용할 수 있습니다."); | ||
} | ||
result += item; | ||
} | ||
return result; | ||
}; | ||
Array.prototype.min = function (selector) { | ||
let result; | ||
for (let i = 0; i < this.length; i++) { | ||
const item = selector ? selector(this[i], i) : this[i]; | ||
if (typeof item !== "number") { | ||
throw new Error("sum 은 number 에 대해서만 사용할 수 있습니다."); | ||
} | ||
if (!result || result > item) { | ||
result = item; | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.max = function (selector) { | ||
let result; | ||
for (let i = 0; i < this.length; i++) { | ||
const item = selector ? selector(this[i], i) : this[i]; | ||
if (typeof item !== "number") { | ||
throw new Error("sum 은 number 에 대해서만 사용할 수 있습니다."); | ||
} | ||
if (!result || result < item) { | ||
result = item; | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.shuffle = function () { | ||
if (this.length <= 1) { | ||
return ObjectUtil_1.ObjectUtil.clone(this); | ||
} | ||
let result = this; | ||
while (true) { | ||
result = result.orderBy(() => Math.random()); | ||
if (!ObjectUtil_1.ObjectUtil.equal(result, this)) { | ||
break; | ||
} | ||
} | ||
return result; | ||
}; | ||
Array.prototype.insert = function (index, item) { | ||
this.splice(index, 0, item); | ||
return this; | ||
}; | ||
Array.prototype.remove = function (itemOrSelector) { | ||
const removeItems = typeof itemOrSelector === "function" ? this.filter(itemOrSelector.bind(this)) : [itemOrSelector]; | ||
for (const removeItem of removeItems) { | ||
while (this.indexOf(removeItem) >= 0) { | ||
this.splice(this.indexOf(removeItem), 1); | ||
} | ||
} | ||
return this; | ||
}; | ||
Array.prototype.clear = function () { | ||
return this.remove(() => true); | ||
}; | ||
/***/ }), | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const PropertyGetSetDecoratorBase_1 = __webpack_require__(8); | ||
function NotifyPropertyChange() { | ||
return PropertyGetSetDecoratorBase_1.PropertyGetSetDecoratorBase({ | ||
afterSet: (target, propertyName, oldValue, newValue) => { | ||
target.onPropertyChange(propertyName, oldValue, newValue); | ||
} | ||
}); | ||
} | ||
exports.NotifyPropertyChange = NotifyPropertyChange; | ||
/***/ }), | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const PropertyGetSetDecoratorBase_1 = __webpack_require__(8); | ||
const ObjectUtil_1 = __webpack_require__(2); | ||
function PropertyValidate(def) { | ||
return PropertyGetSetDecoratorBase_1.PropertyGetSetDecoratorBase({ | ||
beforeSet: (target, propertyName) => { | ||
const error = ObjectUtil_1.ObjectUtil.validate(target[propertyName], def); | ||
if (error) { | ||
throw new Error(`입력값이 잘못되었습니다: ${JSON.stringify({ | ||
component: target.constructor.name, | ||
propertyName, | ||
value: error.value, | ||
errorKeys: Object.keys(error.invalidateDef) | ||
})}`); | ||
} | ||
} | ||
}); | ||
} | ||
exports.PropertyValidate = PropertyValidate; | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __webpack_require__(1); | ||
class NotImplementError extends CustomError_1.CustomError { | ||
constructor(message) { | ||
super("구현되어있지 않습니다" + (message ? ": " + message : "")); | ||
} | ||
} | ||
exports.NotImplementError = NotImplementError; | ||
/***/ }), | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/***/ }), | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class FunctionUtil { | ||
static parse(fn) { | ||
let matches = fn.toString().match(/function\s?\(([^)]*)\)[^{]*{((?!return)(.|\r|\n))*return\s?((.|\r|\n)*);?\s?}$/); | ||
if (matches === null) { | ||
matches = fn.toString().match(/^\(?([^)]*)\)?(\s?)=>(\s?)(.*)$/); | ||
if (matches === null) { | ||
throw new Error("Function 파싱 실패: " + fn.toString() + "\n"); | ||
} | ||
if (!matches[4]) { | ||
throw new Error("Function 파싱 실패: " + fn.toString() + "\n"); | ||
} | ||
if (matches[4].startsWith("{")) { | ||
const newMatch = matches[4].match(/(?!return)(.|\r|\n)*return\s((.|\r|\n)*);/); | ||
if (newMatch && newMatch[2]) { | ||
matches[4] = newMatch[2]; | ||
} | ||
else { | ||
throw new Error("Function 파싱 실패: " + fn.toString() + "\n"); | ||
} | ||
} | ||
} | ||
const params = matches[1].split(",").map((item) => item.trim()); | ||
let returnContent = matches[4].trim(); | ||
if (returnContent.endsWith(";")) { | ||
returnContent = returnContent.slice(0, -1); | ||
} | ||
return { | ||
params, | ||
returnContent | ||
}; | ||
} | ||
} | ||
exports.FunctionUtil = FunctionUtil; | ||
/***/ }), | ||
/* 19 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DateTime_1 = __webpack_require__(3); | ||
const DateOnly_1 = __webpack_require__(5); | ||
const Time_1 = __webpack_require__(6); | ||
const Uuid_1 = __webpack_require__(7); | ||
class JsonConvert { | ||
static stringify(obj, options) { | ||
var _a; | ||
function replacer(key, value) { | ||
var _a, _b, _c; | ||
const currValue = ((_a = options) === null || _a === void 0 ? void 0 : _a.replacer) ? options.replacer(key, value) : value; | ||
if (currValue instanceof Date) { | ||
return { __type__: "Date", data: currValue.toISOString() }; | ||
} | ||
if (currValue instanceof DateTime_1.DateTime) { | ||
return { __type__: "DateTime", data: currValue.toString() }; | ||
} | ||
else if (currValue instanceof DateOnly_1.DateOnly) { | ||
return { __type__: "DateOnly", data: currValue.toString() }; | ||
} | ||
else if (currValue instanceof Time_1.Time) { | ||
return { __type__: "Time", data: currValue.toString() }; | ||
} | ||
else if (currValue instanceof Uuid_1.Uuid) { | ||
return { __type__: "Uuid", data: currValue.toString() }; | ||
} | ||
else if (currValue instanceof Error) { | ||
return { | ||
__type__: "Error", | ||
data: { | ||
message: currValue.message, | ||
name: currValue.name, | ||
stack: currValue.stack, | ||
...currValue | ||
} | ||
}; | ||
} | ||
else if (currValue instanceof Buffer || ((_b = currValue) === null || _b === void 0 ? void 0 : _b.type) === "Buffer") { | ||
return { __type__: "Buffer", data: ((_c = options) === null || _c === void 0 ? void 0 : _c.hideBuffer) ? "__hidden__" : value["data"] }; | ||
} | ||
return currValue; | ||
} | ||
const prevDateToJson = Date.prototype.toJSON; | ||
delete Date.prototype.toJSON; | ||
const result1 = JSON.stringify(replacer(undefined, obj), replacer, (_a = options) === null || _a === void 0 ? void 0 : _a.space); | ||
Date.prototype.toJSON = prevDateToJson; | ||
return result1; | ||
} | ||
static parse(json) { | ||
return json && JSON.parse(json, (key, value) => { | ||
if (value == undefined) { | ||
return undefined; | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Date") { | ||
return new Date(Date.parse(value.data)); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "DateTime") { | ||
return DateTime_1.DateTime.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "DateOnly") { | ||
return DateOnly_1.DateOnly.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Time") { | ||
return Time_1.Time.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Uuid") { | ||
return new Uuid_1.Uuid(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Error") { | ||
const error = new Error(value.data.message); | ||
Object.assign(error, value.data); | ||
return error; | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Buffer") { | ||
return Buffer.from(value.data); | ||
} | ||
return value; | ||
}); | ||
} | ||
} | ||
exports.JsonConvert = JsonConvert; | ||
/***/ }), | ||
/* 20 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class MathUtil { | ||
static getRandomInt(min, max) { | ||
return Math.floor((Math.random() * (max - min)) + min); | ||
} | ||
} | ||
exports.MathUtil = MathUtil; | ||
/***/ }), | ||
/* 21 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const TimeoutError_1 = __webpack_require__(9); | ||
class Wait { | ||
static async true(forwarder, milliseconds, timeout) { | ||
let currMs = 0; | ||
while (true) { | ||
if (await forwarder()) { | ||
break; | ||
} | ||
await Wait.time((milliseconds !== null && milliseconds !== void 0 ? milliseconds : 100)); | ||
if (timeout) { | ||
currMs += (milliseconds !== null && milliseconds !== void 0 ? milliseconds : 100); | ||
if (currMs >= timeout) { | ||
throw new TimeoutError_1.TimeoutError(); | ||
} | ||
} | ||
} | ||
} | ||
static async time(millisecond) { | ||
await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, millisecond); | ||
}); | ||
} | ||
} | ||
exports.Wait = Wait; | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
var tslib_1 = require("tslib"); | ||
require("core-js"); | ||
require("./extension/ArrayExtension"); | ||
tslib_1.__exportStar(require("./decorator/NotifyPropertyChange"), exports); | ||
tslib_1.__exportStar(require("./decorator/PropertyGetSetDecoratorBase"), exports); | ||
tslib_1.__exportStar(require("./decorator/PropertyValidate"), exports); | ||
tslib_1.__exportStar(require("./error/ArgumentError"), exports); | ||
tslib_1.__exportStar(require("./error/CustomError"), exports); | ||
tslib_1.__exportStar(require("./error/NotImplementError"), exports); | ||
tslib_1.__exportStar(require("./error/TimeoutError"), exports); | ||
tslib_1.__exportStar(require("./commons"), exports); | ||
tslib_1.__exportStar(require("./type/DateOnly"), exports); | ||
tslib_1.__exportStar(require("./type/DateTime"), exports); | ||
tslib_1.__exportStar(require("./type/Time"), exports); | ||
tslib_1.__exportStar(require("./type/Uuid"), exports); | ||
tslib_1.__exportStar(require("./util/FunctionUtil"), exports); | ||
tslib_1.__exportStar(require("./util/JsonConvert"), exports); | ||
tslib_1.__exportStar(require("./util/MathUtil"), exports); | ||
tslib_1.__exportStar(require("./util/ObjectUtil"), exports); | ||
tslib_1.__exportStar(require("./util/Wait"), exports); | ||
//# sourceMappingURL=module.js.map |
{ | ||
"name": "@simplysm/sd-core-common", | ||
"version": "3.1.124", | ||
"version": "3.1.133", | ||
"description": "심플리즘 패키지 - 코어 모듈 (browser/node)", | ||
@@ -5,0 +5,0 @@ "author": "김석래", |
@@ -5,7 +5,7 @@ export class CustomError extends Error { | ||
public constructor(arg1?: Error | string, arg2?: string) { | ||
if (arg1 instanceof Error || typeof arg2 === "string") { | ||
if ((arg1 && arg1["message"] && arg1["stack"]) || typeof arg2 === "string") { | ||
super(arg2 + (arg1 instanceof Error ? ` => ${arg1.message}` : "")); | ||
} | ||
else { | ||
super(arg1); | ||
super(arg1 as string); | ||
} | ||
@@ -27,6 +27,6 @@ | ||
if (arg1 instanceof Error && arg1.stack) { | ||
this.stack += "\n-- inner error stack --\n" + arg1.stack; | ||
if (arg1 && arg1["message"] && arg1["stack"]) { | ||
this.stack += "\n-- inner error stack --\n" + arg1["stack"]; | ||
} | ||
} | ||
} | ||
} |
@@ -10,6 +10,3 @@ { | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
], | ||
"compileOnSave": false | ||
} |
@@ -9,6 +9,3 @@ { | ||
"declaration": false | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
] | ||
} | ||
} |
@@ -11,6 +11,3 @@ { | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
], | ||
"compileOnSave": false | ||
} |
@@ -10,6 +10,3 @@ { | ||
"outDir": "dist" | ||
}, | ||
"files": [ | ||
"src/index.ts" | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
86
170088
3077