@simplysm/core-common 13.0.99 → 14.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/common.types.d.ts +14 -14
  2. package/dist/common.types.js +2 -1
  3. package/dist/common.types.js.map +1 -6
  4. package/dist/env.d.ts +5 -0
  5. package/dist/env.d.ts.map +1 -1
  6. package/dist/env.js +12 -8
  7. package/dist/env.js.map +1 -6
  8. package/dist/errors/argument-error.d.ts +10 -10
  9. package/dist/errors/argument-error.d.ts.map +1 -1
  10. package/dist/errors/argument-error.js +31 -14
  11. package/dist/errors/argument-error.js.map +1 -6
  12. package/dist/errors/not-implemented-error.d.ts +8 -8
  13. package/dist/errors/not-implemented-error.js +30 -12
  14. package/dist/errors/not-implemented-error.js.map +1 -6
  15. package/dist/errors/sd-error.d.ts +10 -10
  16. package/dist/errors/sd-error.d.ts.map +1 -1
  17. package/dist/errors/sd-error.js +45 -24
  18. package/dist/errors/sd-error.js.map +1 -6
  19. package/dist/errors/timeout-error.d.ts +10 -10
  20. package/dist/errors/timeout-error.js +34 -15
  21. package/dist/errors/timeout-error.js.map +1 -6
  22. package/dist/extensions/arr-ext.d.ts +2 -2
  23. package/dist/extensions/arr-ext.helpers.d.ts +10 -10
  24. package/dist/extensions/arr-ext.helpers.js +112 -89
  25. package/dist/extensions/arr-ext.helpers.js.map +1 -6
  26. package/dist/extensions/arr-ext.js +458 -422
  27. package/dist/extensions/arr-ext.js.map +1 -6
  28. package/dist/extensions/arr-ext.types.d.ts +57 -57
  29. package/dist/extensions/arr-ext.types.d.ts.map +1 -1
  30. package/dist/extensions/arr-ext.types.js +6 -1
  31. package/dist/extensions/arr-ext.types.js.map +1 -6
  32. package/dist/extensions/map-ext.d.ts +16 -16
  33. package/dist/extensions/map-ext.js +27 -22
  34. package/dist/extensions/map-ext.js.map +1 -6
  35. package/dist/extensions/set-ext.d.ts +11 -11
  36. package/dist/extensions/set-ext.js +32 -25
  37. package/dist/extensions/set-ext.js.map +1 -6
  38. package/dist/features/debounce-queue.d.ts +17 -17
  39. package/dist/features/debounce-queue.js +98 -70
  40. package/dist/features/debounce-queue.js.map +1 -6
  41. package/dist/features/event-emitter.d.ts +20 -20
  42. package/dist/features/event-emitter.js +101 -78
  43. package/dist/features/event-emitter.js.map +1 -6
  44. package/dist/features/serial-queue.d.ts +11 -11
  45. package/dist/features/serial-queue.js +78 -57
  46. package/dist/features/serial-queue.js.map +1 -6
  47. package/dist/globals.d.ts +4 -4
  48. package/dist/globals.js +9 -1
  49. package/dist/globals.js.map +1 -6
  50. package/dist/index.js +28 -27
  51. package/dist/index.js.map +1 -6
  52. package/dist/types/date-only.d.ts +64 -64
  53. package/dist/types/date-only.d.ts.map +1 -1
  54. package/dist/types/date-only.js +263 -252
  55. package/dist/types/date-only.js.map +1 -6
  56. package/dist/types/date-time.d.ts +36 -36
  57. package/dist/types/date-time.d.ts.map +1 -1
  58. package/dist/types/date-time.js +196 -288
  59. package/dist/types/date-time.js.map +1 -6
  60. package/dist/types/lazy-gc-map.d.ts +26 -26
  61. package/dist/types/lazy-gc-map.d.ts.map +1 -1
  62. package/dist/types/lazy-gc-map.js +202 -159
  63. package/dist/types/lazy-gc-map.js.map +1 -6
  64. package/dist/types/time.d.ts +23 -23
  65. package/dist/types/time.d.ts.map +1 -1
  66. package/dist/types/time.js +169 -158
  67. package/dist/types/time.js.map +1 -6
  68. package/dist/types/uuid.d.ts +11 -11
  69. package/dist/types/uuid.d.ts.map +1 -1
  70. package/dist/types/uuid.js +95 -70
  71. package/dist/types/uuid.js.map +1 -6
  72. package/dist/utils/bytes.d.ts +17 -17
  73. package/dist/utils/bytes.js +137 -81
  74. package/dist/utils/bytes.js.map +1 -6
  75. package/dist/utils/date-format.d.ts +40 -40
  76. package/dist/utils/date-format.js +187 -101
  77. package/dist/utils/date-format.js.map +1 -6
  78. package/dist/utils/error.d.ts +4 -4
  79. package/dist/utils/error.js +11 -6
  80. package/dist/utils/error.js.map +1 -6
  81. package/dist/utils/json.d.ts +19 -19
  82. package/dist/utils/json.js +187 -135
  83. package/dist/utils/json.js.map +1 -6
  84. package/dist/utils/num.d.ts +20 -20
  85. package/dist/utils/num.js +76 -34
  86. package/dist/utils/num.js.map +1 -6
  87. package/dist/utils/obj.d.ts +111 -111
  88. package/dist/utils/obj.d.ts.map +1 -1
  89. package/dist/utils/obj.js +706 -496
  90. package/dist/utils/obj.js.map +1 -6
  91. package/dist/utils/path.d.ts +10 -10
  92. package/dist/utils/path.js +35 -18
  93. package/dist/utils/path.js.map +1 -6
  94. package/dist/utils/primitive.d.ts +5 -5
  95. package/dist/utils/primitive.js +34 -14
  96. package/dist/utils/primitive.js.map +1 -6
  97. package/dist/utils/str.d.ts +38 -38
  98. package/dist/utils/str.js +217 -113
  99. package/dist/utils/str.js.map +1 -6
  100. package/dist/utils/template-strings.d.ts +26 -26
  101. package/dist/utils/template-strings.js +113 -40
  102. package/dist/utils/template-strings.js.map +1 -6
  103. package/dist/utils/transferable.d.ts +18 -18
  104. package/dist/utils/transferable.js +218 -151
  105. package/dist/utils/transferable.js.map +1 -6
  106. package/dist/utils/wait.d.ts +9 -9
  107. package/dist/utils/wait.js +30 -15
  108. package/dist/utils/wait.js.map +1 -6
  109. package/dist/utils/xml.d.ts +13 -13
  110. package/dist/utils/xml.js +84 -46
  111. package/dist/utils/xml.js.map +1 -6
  112. package/dist/utils/zip.d.ts +22 -22
  113. package/dist/utils/zip.js +172 -148
  114. package/dist/utils/zip.js.map +1 -6
  115. package/package.json +5 -7
  116. package/src/common.types.ts +14 -14
  117. package/src/env.ts +9 -1
  118. package/src/errors/argument-error.ts +15 -15
  119. package/src/errors/not-implemented-error.ts +9 -9
  120. package/src/errors/sd-error.ts +12 -12
  121. package/src/errors/timeout-error.ts +12 -12
  122. package/src/extensions/arr-ext.helpers.ts +16 -16
  123. package/src/extensions/arr-ext.ts +35 -35
  124. package/src/extensions/arr-ext.types.ts +57 -57
  125. package/src/extensions/map-ext.ts +16 -16
  126. package/src/extensions/set-ext.ts +11 -11
  127. package/src/features/debounce-queue.ts +23 -23
  128. package/src/features/event-emitter.ts +25 -25
  129. package/src/features/serial-queue.ts +13 -13
  130. package/src/globals.ts +4 -4
  131. package/src/index.ts +5 -5
  132. package/src/types/date-only.ts +84 -83
  133. package/src/types/date-time.ts +43 -42
  134. package/src/types/lazy-gc-map.ts +44 -44
  135. package/src/types/time.ts +29 -29
  136. package/src/types/uuid.ts +15 -15
  137. package/src/utils/bytes.ts +35 -35
  138. package/src/utils/date-format.ts +59 -59
  139. package/src/utils/error.ts +4 -4
  140. package/src/utils/json.ts +41 -41
  141. package/src/utils/num.ts +20 -20
  142. package/src/utils/obj.ts +138 -138
  143. package/src/utils/path.ts +10 -10
  144. package/src/utils/primitive.ts +6 -6
  145. package/src/utils/str.ts +48 -48
  146. package/src/utils/template-strings.ts +29 -29
  147. package/src/utils/transferable.ts +38 -38
  148. package/src/utils/wait.ts +10 -10
  149. package/src/utils/xml.ts +19 -19
  150. package/src/utils/zip.ts +25 -25
  151. package/README.md +0 -160
  152. package/docs/errors.md +0 -119
  153. package/docs/extensions.md +0 -387
  154. package/docs/features.md +0 -143
  155. package/docs/types.md +0 -287
  156. package/docs/utils.md +0 -757
  157. package/tests/errors/errors.spec.ts +0 -80
  158. package/tests/extensions/array-extension.spec.ts +0 -654
  159. package/tests/extensions/map-extension.spec.ts +0 -117
  160. package/tests/extensions/set-extension.spec.ts +0 -67
  161. package/tests/types/date-only.spec.ts +0 -533
  162. package/tests/types/date-time.spec.ts +0 -246
  163. package/tests/types/lazy-gc-map.spec.ts +0 -606
  164. package/tests/types/time.spec.ts +0 -428
  165. package/tests/types/uuid.spec.ts +0 -74
  166. package/tests/utils/bytes-utils.spec.ts +0 -197
  167. package/tests/utils/date-format.spec.ts +0 -350
  168. package/tests/utils/debounce-queue.spec.ts +0 -226
  169. package/tests/utils/json.spec.ts +0 -400
  170. package/tests/utils/number.spec.ts +0 -136
  171. package/tests/utils/object.spec.ts +0 -810
  172. package/tests/utils/path.spec.ts +0 -70
  173. package/tests/utils/primitive.spec.ts +0 -43
  174. package/tests/utils/sd-event-emitter.spec.ts +0 -189
  175. package/tests/utils/serial-queue.spec.ts +0 -305
  176. package/tests/utils/string.spec.ts +0 -265
  177. package/tests/utils/template-strings.spec.ts +0 -48
  178. package/tests/utils/transferable.spec.ts +0 -639
  179. package/tests/utils/wait.spec.ts +0 -123
  180. package/tests/utils/xml.spec.ts +0 -146
  181. package/tests/utils/zip.spec.ts +0 -221
package/docs/types.md DELETED
@@ -1,287 +0,0 @@
1
- # Types
2
-
3
- Data types and common type definitions.
4
-
5
- Source: `src/types/*.ts`, `src/common.types.ts`, `src/env.ts`
6
-
7
- ---
8
-
9
- ## `Uuid`
10
-
11
- UUID v4 class. Generates cryptographically secure UUIDs based on `crypto.getRandomValues` (Chrome 79+, Node.js compatible).
12
-
13
- ```typescript
14
- export class Uuid {
15
- /** Create new UUID v4 instance */
16
- static generate(): Uuid;
17
-
18
- /**
19
- * Create UUID from 16-byte Uint8Array
20
- * @throws {ArgumentError} If byte size is not 16
21
- */
22
- static fromBytes(bytes: Bytes): Uuid;
23
-
24
- /**
25
- * @param uuid UUID string (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
26
- * @throws {ArgumentError} If format is invalid
27
- */
28
- constructor(uuid: string);
29
-
30
- /** Convert UUID to string */
31
- toString(): string;
32
-
33
- /** Convert UUID to 16-byte Uint8Array */
34
- toBytes(): Bytes;
35
- }
36
- ```
37
-
38
- ---
39
-
40
- ## `DateTime`
41
-
42
- Immutable date+time class wrapping JavaScript `Date`. Supports millisecond precision and operates based on local timezone.
43
-
44
- ```typescript
45
- export class DateTime {
46
- readonly date: Date;
47
-
48
- /** Create with current time */
49
- constructor();
50
- /** Create with year, month, day, hour, minute, second, millisecond */
51
- constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
52
- /** Create from tick (millisecond) */
53
- constructor(tick: number);
54
- /** Create from Date object */
55
- constructor(date: Date);
56
-
57
- /**
58
- * Parse a string to create DateTime instance
59
- * Supported formats: 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm:ss.fff', 'yyyyMMddHHmmss',
60
- * 'yyyy-MM-dd AM/PM HH:mm:ss', Korean AM/PM (오전/오후), ISO 8601
61
- * @throws ArgumentError If unsupported format
62
- */
63
- static parse(str: string): DateTime;
64
- }
65
- ```
66
-
67
- **Getters** (read-only): `year`, `month`, `day`, `hour`, `minute`, `second`, `millisecond`, `tick`, `dayOfWeek` (0=Sunday), `timezoneOffsetMinutes`, `isValid`
68
-
69
- **Immutable setters** (return new instance): `setYear(year)`, `setMonth(month)`, `setDay(day)`, `setHour(hour)`, `setMinute(minute)`, `setSecond(second)`, `setMillisecond(millisecond)`
70
-
71
- **Arithmetic** (return new instance): `addYears(n)`, `addMonths(n)`, `addDays(n)`, `addHours(n)`, `addMinutes(n)`, `addSeconds(n)`, `addMilliseconds(n)`
72
-
73
- **Formatting**: `toFormatString(formatStr)`, `toString()` (default: `"yyyy-MM-ddTHH:mm:ss.fffzzz"`)
74
-
75
- ---
76
-
77
- ## `DateOnly`
78
-
79
- Immutable date class (without time: `yyyy-MM-dd`). Operates based on local timezone.
80
-
81
- ```typescript
82
- export class DateOnly {
83
- readonly date: Date;
84
-
85
- /** Current date */
86
- constructor();
87
- /** Initialize with year, month, day */
88
- constructor(year: number, month: number, day: number);
89
- /** Create from tick (millisecond) */
90
- constructor(tick: number);
91
- /** Create from Date type */
92
- constructor(date: Date);
93
-
94
- /**
95
- * Parse a string into DateOnly
96
- * Supported formats: 'yyyy-MM-dd', 'yyyyMMdd', ISO 8601
97
- */
98
- static parse(str: string): DateOnly;
99
-
100
- /**
101
- * Get the start date of a week based on week information
102
- */
103
- static getDateByYearWeekSeq(
104
- arg: { year: number; month?: number; weekSeq: number },
105
- weekStartDay?: number,
106
- minDaysInFirstWeek?: number,
107
- ): DateOnly;
108
- }
109
- ```
110
-
111
- **Getters** (read-only): `year`, `month`, `day`, `tick`, `dayOfWeek`, `isValid`
112
-
113
- **Immutable setters**: `setYear(year)`, `setMonth(month)`, `setDay(day)`
114
-
115
- **Arithmetic**: `addYears(n)`, `addMonths(n)`, `addDays(n)`
116
-
117
- **Week calculation methods**:
118
-
119
- ```typescript
120
- getBaseYearMonthSeqForWeekSeq(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; monthSeq: number };
121
- getWeekSeqStartDate(weekStartDay?: number, minDaysInFirstWeek?: number): DateOnly;
122
- getWeekSeqOfYear(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; weekSeq: number };
123
- getWeekSeqOfMonth(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; monthSeq: number; weekSeq: number };
124
- ```
125
-
126
- Defaults: `weekStartDay = 1` (Monday), `minDaysInFirstWeek = 4` (ISO 8601 standard).
127
-
128
- **Formatting**: `toFormatString(formatStr)`, `toString()` (default: `"yyyy-MM-dd"`)
129
-
130
- ---
131
-
132
- ## `Time`
133
-
134
- Immutable time class (without date: `HH:mm:ss.fff`). Values exceeding 24 hours or negative values are automatically normalized (24-hour wraparound).
135
-
136
- ```typescript
137
- export class Time {
138
- /** Create with current time */
139
- constructor();
140
- /** Create with hour, minute, second, millisecond */
141
- constructor(hour: number, minute: number, second?: number, millisecond?: number);
142
- /** Create from tick (millisecond) */
143
- constructor(tick: number);
144
- /** Create by extracting time part only from Date object */
145
- constructor(date: Date);
146
-
147
- /**
148
- * Parse a string to create Time instance
149
- * Supported formats: 'HH:mm:ss', 'HH:mm:ss.fff', 'AM/PM HH:mm:ss', ISO 8601 (extract time part)
150
- * @throws ArgumentError If unsupported format
151
- */
152
- static parse(str: string): Time;
153
- }
154
- ```
155
-
156
- **Getters**: `hour`, `minute`, `second`, `millisecond`, `tick`, `isValid`
157
-
158
- **Immutable setters**: `setHour(hour)`, `setMinute(minute)`, `setSecond(second)`, `setMillisecond(millisecond)`
159
-
160
- **Arithmetic** (24-hour wraparound): `addHours(n)`, `addMinutes(n)`, `addSeconds(n)`, `addMilliseconds(n)`
161
-
162
- **Formatting**: `toFormatString(formatStr)`, `toString()` (default: `"HH:mm:ss.fff"`)
163
-
164
- ---
165
-
166
- ## `LazyGcMap`
167
-
168
- Map with automatic expiration feature. Updates access time in LRU manner; auto-deletes if not accessed for specified time. Supports the `using` statement (`Symbol.dispose`).
169
-
170
- ```typescript
171
- export class LazyGcMap<TKey, TValue> {
172
- /**
173
- * @param options.gcInterval GC interval in ms. Default: 1/10 of expireTime (minimum 1000ms)
174
- * @param options.expireTime Expiration time in ms since last access
175
- * @param options.onExpire Callback called on expiration (can be async)
176
- */
177
- constructor(options: {
178
- gcInterval?: number;
179
- expireTime: number;
180
- onExpire?: (key: TKey, value: TValue) => void | Promise<void>;
181
- });
182
-
183
- get size(): number;
184
- has(key: TKey): boolean;
185
- get(key: TKey): TValue | undefined;
186
- set(key: TKey, value: TValue): void;
187
- delete(key: TKey): boolean;
188
- clear(): void;
189
- getOrCreate(key: TKey, factory: () => TValue): TValue;
190
- values(): IterableIterator<TValue>;
191
- keys(): IterableIterator<TKey>;
192
- entries(): IterableIterator<[TKey, TValue]>;
193
- dispose(): void;
194
- [Symbol.dispose](): void;
195
- }
196
- ```
197
-
198
- **Example:**
199
-
200
- ```typescript
201
- using map = new LazyGcMap({ gcInterval: 10000, expireTime: 60000 });
202
- map.set("session", data);
203
- const val = map.getOrCreate("key", () => computeExpensive());
204
- ```
205
-
206
- ---
207
-
208
- ## `Bytes`
209
-
210
- Binary type alias used instead of `Buffer`.
211
-
212
- ```typescript
213
- export type Bytes = Uint8Array;
214
- ```
215
-
216
- ---
217
-
218
- ## `PrimitiveTypeMap`
219
-
220
- Primitive type mapping shared with orm-common.
221
-
222
- ```typescript
223
- export type PrimitiveTypeMap = {
224
- string: string;
225
- number: number;
226
- boolean: boolean;
227
- DateTime: DateTime;
228
- DateOnly: DateOnly;
229
- Time: Time;
230
- Uuid: Uuid;
231
- Bytes: Bytes;
232
- };
233
- ```
234
-
235
- ---
236
-
237
- ## `PrimitiveTypeStr`
238
-
239
- ```typescript
240
- export type PrimitiveTypeStr = keyof PrimitiveTypeMap;
241
- ```
242
-
243
- ---
244
-
245
- ## `PrimitiveType`
246
-
247
- ```typescript
248
- export type PrimitiveType = PrimitiveTypeMap[PrimitiveTypeStr] | undefined;
249
- ```
250
-
251
- ---
252
-
253
- ## `DeepPartial<T>`
254
-
255
- Recursively makes all properties of an object optional. Primitive types are kept as-is.
256
-
257
- ```typescript
258
- export type DeepPartial<TObject> = Partial<{
259
- [K in keyof TObject]: TObject[K] extends PrimitiveType ? TObject[K] : DeepPartial<TObject[K]>;
260
- }>;
261
- ```
262
-
263
- ---
264
-
265
- ## `Type<T>`
266
-
267
- Constructor type used for dependency injection, factory patterns, and `instanceof` checks.
268
-
269
- ```typescript
270
- export interface Type<TInstance> extends Function {
271
- new (...args: unknown[]): TInstance;
272
- }
273
- ```
274
-
275
- ---
276
-
277
- ## `env`
278
-
279
- Unified environment variable accessor. Merges `import.meta.env` and `process.env`. `DEV` is parsed as boolean, `VER` as optional string.
280
-
281
- ```typescript
282
- export const env: {
283
- DEV: boolean;
284
- VER?: string;
285
- [key: string]: unknown;
286
- };
287
- ```