@simplysm/core-common 13.0.68 → 13.0.70

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 (148) hide show
  1. package/README.md +66 -267
  2. package/dist/common.types.d.ts +14 -14
  3. package/dist/errors/argument-error.d.ts +10 -10
  4. package/dist/errors/argument-error.d.ts.map +1 -1
  5. package/dist/errors/argument-error.js +2 -2
  6. package/dist/errors/argument-error.js.map +1 -1
  7. package/dist/errors/not-implemented-error.d.ts +8 -8
  8. package/dist/errors/not-implemented-error.js +2 -2
  9. package/dist/errors/not-implemented-error.js.map +1 -1
  10. package/dist/errors/sd-error.d.ts +10 -10
  11. package/dist/errors/sd-error.d.ts.map +1 -1
  12. package/dist/errors/timeout-error.d.ts +10 -10
  13. package/dist/errors/timeout-error.js +3 -3
  14. package/dist/errors/timeout-error.js.map +1 -1
  15. package/dist/extensions/arr-ext.d.ts +2 -2
  16. package/dist/extensions/arr-ext.helpers.d.ts +8 -8
  17. package/dist/extensions/arr-ext.helpers.js +1 -1
  18. package/dist/extensions/arr-ext.helpers.js.map +1 -1
  19. package/dist/extensions/arr-ext.js +13 -13
  20. package/dist/extensions/arr-ext.js.map +1 -1
  21. package/dist/extensions/arr-ext.types.d.ts +57 -57
  22. package/dist/extensions/arr-ext.types.d.ts.map +1 -1
  23. package/dist/extensions/map-ext.d.ts +16 -16
  24. package/dist/extensions/set-ext.d.ts +11 -11
  25. package/dist/features/debounce-queue.d.ts +17 -15
  26. package/dist/features/debounce-queue.d.ts.map +1 -1
  27. package/dist/features/debounce-queue.js +6 -6
  28. package/dist/features/debounce-queue.js.map +1 -1
  29. package/dist/features/event-emitter.d.ts +20 -20
  30. package/dist/features/event-emitter.js +17 -17
  31. package/dist/features/serial-queue.d.ts +11 -11
  32. package/dist/features/serial-queue.js +5 -5
  33. package/dist/features/serial-queue.js.map +1 -1
  34. package/dist/globals.d.ts +4 -4
  35. package/dist/types/date-only.d.ts +64 -64
  36. package/dist/types/date-only.d.ts.map +1 -1
  37. package/dist/types/date-only.js +63 -63
  38. package/dist/types/date-time.d.ts +37 -37
  39. package/dist/types/date-time.d.ts.map +1 -1
  40. package/dist/types/date-time.js +54 -37
  41. package/dist/types/date-time.js.map +1 -1
  42. package/dist/types/lazy-gc-map.d.ts +26 -26
  43. package/dist/types/lazy-gc-map.d.ts.map +1 -1
  44. package/dist/types/lazy-gc-map.js +26 -26
  45. package/dist/types/lazy-gc-map.js.map +1 -1
  46. package/dist/types/time.d.ts +25 -25
  47. package/dist/types/time.d.ts.map +1 -1
  48. package/dist/types/time.js +25 -25
  49. package/dist/types/time.js.map +1 -1
  50. package/dist/types/uuid.d.ts +11 -11
  51. package/dist/types/uuid.d.ts.map +1 -1
  52. package/dist/types/uuid.js +12 -12
  53. package/dist/types/uuid.js.map +1 -1
  54. package/dist/utils/bytes.d.ts +17 -17
  55. package/dist/utils/bytes.js +4 -4
  56. package/dist/utils/bytes.js.map +1 -1
  57. package/dist/utils/date-format.d.ts +45 -45
  58. package/dist/utils/date-format.js +1 -1
  59. package/dist/utils/date-format.js.map +1 -1
  60. package/dist/utils/error.d.ts +4 -4
  61. package/dist/utils/json.d.ts +17 -17
  62. package/dist/utils/json.js +3 -3
  63. package/dist/utils/json.js.map +1 -1
  64. package/dist/utils/num.d.ts +23 -23
  65. package/dist/utils/obj.d.ts +111 -111
  66. package/dist/utils/obj.d.ts.map +1 -1
  67. package/dist/utils/obj.js +3 -3
  68. package/dist/utils/obj.js.map +1 -1
  69. package/dist/utils/path.d.ts +10 -10
  70. package/dist/utils/primitive.d.ts +5 -5
  71. package/dist/utils/primitive.js +1 -1
  72. package/dist/utils/primitive.js.map +1 -1
  73. package/dist/utils/str.d.ts +46 -46
  74. package/dist/utils/str.d.ts.map +1 -1
  75. package/dist/utils/str.js +5 -5
  76. package/dist/utils/str.js.map +1 -1
  77. package/dist/utils/template-strings.d.ts +26 -26
  78. package/dist/utils/transferable.d.ts +18 -18
  79. package/dist/utils/transferable.js +1 -1
  80. package/dist/utils/transferable.js.map +1 -1
  81. package/dist/utils/wait.d.ts +9 -9
  82. package/dist/utils/xml.d.ts +13 -13
  83. package/dist/zip/sd-zip.d.ts +22 -22
  84. package/dist/zip/sd-zip.js +16 -16
  85. package/package.json +4 -4
  86. package/src/common.types.ts +17 -17
  87. package/src/errors/argument-error.ts +15 -15
  88. package/src/errors/not-implemented-error.ts +9 -9
  89. package/src/errors/sd-error.ts +12 -12
  90. package/src/errors/timeout-error.ts +12 -12
  91. package/src/extensions/arr-ext.helpers.ts +10 -10
  92. package/src/extensions/arr-ext.ts +57 -57
  93. package/src/extensions/arr-ext.types.ts +59 -59
  94. package/src/extensions/map-ext.ts +16 -16
  95. package/src/extensions/set-ext.ts +11 -11
  96. package/src/features/debounce-queue.ts +21 -19
  97. package/src/features/event-emitter.ts +25 -25
  98. package/src/features/serial-queue.ts +13 -13
  99. package/src/globals.ts +4 -4
  100. package/src/index.ts +1 -1
  101. package/src/types/date-only.ts +83 -83
  102. package/src/types/date-time.ts +64 -44
  103. package/src/types/lazy-gc-map.ts +45 -45
  104. package/src/types/time.ts +34 -34
  105. package/src/types/uuid.ts +17 -17
  106. package/src/utils/bytes.ts +35 -35
  107. package/src/utils/date-format.ts +65 -65
  108. package/src/utils/error.ts +4 -4
  109. package/src/utils/json.ts +39 -39
  110. package/src/utils/num.ts +23 -23
  111. package/src/utils/obj.ts +138 -138
  112. package/src/utils/path.ts +10 -10
  113. package/src/utils/primitive.ts +6 -6
  114. package/src/utils/str.ts +260 -261
  115. package/src/utils/template-strings.ts +29 -29
  116. package/src/utils/transferable.ts +284 -284
  117. package/src/utils/wait.ts +10 -10
  118. package/src/utils/xml.ts +19 -19
  119. package/src/zip/sd-zip.ts +25 -25
  120. package/tests/errors/errors.spec.ts +80 -0
  121. package/tests/extensions/array-extension.spec.ts +796 -0
  122. package/tests/extensions/map-extension.spec.ts +147 -0
  123. package/tests/extensions/set-extension.spec.ts +74 -0
  124. package/tests/types/date-only.spec.ts +638 -0
  125. package/tests/types/date-time.spec.ts +391 -0
  126. package/tests/types/lazy-gc-map.spec.ts +692 -0
  127. package/tests/types/time.spec.ts +559 -0
  128. package/tests/types/uuid.spec.ts +74 -0
  129. package/tests/utils/bytes-utils.spec.ts +230 -0
  130. package/tests/utils/date-format.spec.ts +373 -0
  131. package/tests/utils/debounce-queue.spec.ts +272 -0
  132. package/tests/utils/json.spec.ts +486 -0
  133. package/tests/utils/number.spec.ts +157 -0
  134. package/tests/utils/object.spec.ts +829 -0
  135. package/tests/utils/path.spec.ts +78 -0
  136. package/tests/utils/primitive.spec.ts +43 -0
  137. package/tests/utils/sd-event-emitter.spec.ts +216 -0
  138. package/tests/utils/serial-queue.spec.ts +365 -0
  139. package/tests/utils/string.spec.ts +281 -0
  140. package/tests/utils/template-strings.spec.ts +57 -0
  141. package/tests/utils/transferable.spec.ts +703 -0
  142. package/tests/utils/wait.spec.ts +145 -0
  143. package/tests/utils/xml.spec.ts +146 -0
  144. package/tests/zip/sd-zip.spec.ts +238 -0
  145. package/docs/extensions.md +0 -503
  146. package/docs/features.md +0 -109
  147. package/docs/types.md +0 -486
  148. package/docs/utils.md +0 -780
package/README.md CHANGED
@@ -1,277 +1,76 @@
1
1
  # @simplysm/core-common
2
2
 
3
- A common utility package for the Simplysm framework. As a neutral base module usable in both Node.js and browser environments, it provides date/time types, error classes, object/array/string utilities, JSON serialization, ZIP processing, prototype extensions, and more.
3
+ Simplysm package - Core module (common)
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
- npm install @simplysm/core-common
9
- # or
10
7
  pnpm add @simplysm/core-common
11
- ```
12
8
 
13
- ### Initialization
14
-
15
- Import the package at your application entry point (e.g., `index.ts`, `main.ts`):
16
-
17
- ```typescript
18
- import "@simplysm/core-common";
19
- ```
20
-
21
- This import globally activates Array, Map, and Set prototype extensions.
22
- To use extension methods (`getOrCreate()`, `toggle()`, etc.), you must import this at app startup.
23
-
24
- ## Main Modules
25
-
26
- ### Errors
27
-
28
- - [`SdError`](docs/types.md#sderror) - Base error class with cause chain tracking
29
- - [`ArgumentError`](docs/types.md#argumenterror) - Argument validation error with YAML formatting
30
- - [`NotImplementedError`](docs/types.md#notimplementederror) - Indicates unimplemented functionality
31
- - [`TimeoutError`](docs/types.md#timeouterror) - Timeout error
32
-
33
- ### Custom Types
34
-
35
- - [`DateTime`](docs/types.md#datetime) - Date + time (millisecond precision, local timezone)
36
- - [`DateOnly`](docs/types.md#dateonly) - Date only (no time)
37
- - [`Time`](docs/types.md#time) - Time only (no date, 24-hour cycle)
38
- - [`Uuid`](docs/types.md#uuid) - UUID v4 (cryptographically secure)
39
- - [`LazyGcMap`](docs/types.md#lazygcmap) - Map with auto-expiration (LRU style)
40
-
41
- ### Features
42
-
43
- - [`DebounceQueue`](docs/features.md#debouncequeue) - Async debounce queue (executes only last request)
44
- - [`SerialQueue`](docs/features.md#serialqueue) - Async serial queue (sequential execution)
45
- - [`EventEmitter`](docs/features.md#eventemitter) - EventTarget wrapper with type-safe events
46
-
47
- ### ZIP
48
-
49
- - [`ZipArchive`](docs/features.md#ziparchive) - ZIP file compression/decompression utility
50
-
51
- ### Object Utilities
52
-
53
- - [`objClone`](docs/utils.md#objclone) - Deep clone (supports circular references, custom types)
54
- - [`objEqual`](docs/utils.md#objequal) - Deep comparison with options
55
- - [`objMerge`](docs/utils.md#objmerge) - Deep merge (source + target)
56
- - [`objMerge3`](docs/utils.md#objmerge3) - 3-way merge with conflict detection
57
- - [`objOmit`](docs/utils.md#objomit) - Exclude specific keys
58
- - [`objOmitByFilter`](docs/utils.md#objomitbyfilter) - Exclude keys matching a predicate
59
- - [`objPick`](docs/utils.md#objpick) - Select specific keys
60
- - [`objGetChainValue`](docs/utils.md#objgetchainvalue) - Query value by chain path
61
- - [`objGetChainValueByDepth`](docs/utils.md#objgetchainvaluebydepth) - Query value by descending the same key repeatedly
62
- - [`objSetChainValue`](docs/utils.md#objsetchainvalue) - Set value by chain path
63
- - [`objDeleteChainValue`](docs/utils.md#objdeletechainvalue) - Delete value by chain path
64
- - [`objClearUndefined`](docs/utils.md#objclearundefined) - Delete keys with `undefined` values (mutates original)
65
- - [`objClear`](docs/utils.md#objclear) - Delete all keys from an object (mutates original)
66
- - [`objNullToUndefined`](docs/utils.md#objnulltoundefined) - Recursively convert null to undefined (mutates original)
67
- - [`objUnflatten`](docs/utils.md#objunflatten) - Convert dot-notation flat object to nested object
68
- - [`objKeys`](docs/utils.md#objkeys) - Type-safe `Object.keys`
69
- - [`objEntries`](docs/utils.md#objentries) - Type-safe `Object.entries`
70
- - [`objFromEntries`](docs/utils.md#objfromentries) - Type-safe `Object.fromEntries`
71
- - [`objMap`](docs/utils.md#objmap) - Transform each entry of object
72
-
73
- ### JSON Utilities
74
-
75
- - [`jsonStringify`](docs/utils.md#jsonstringify) - JSON serialization with custom type support
76
- - [`jsonParse`](docs/utils.md#jsonparse) - JSON deserialization with custom type restoration
77
-
78
- ### XML Utilities
79
-
80
- - [`xmlParse`](docs/utils.md#xmlparse) - Parse XML string to object
81
- - [`xmlStringify`](docs/utils.md#xmlstringify) - Serialize object to XML string
82
-
83
- ### String Utilities
84
-
85
- - [`strGetSuffix`](docs/utils.md#strgetsuffix) - Korean postposition handling
86
- - [`strReplaceFullWidth`](docs/utils.md#strreplacefullwidth) - Convert full-width to half-width
87
- - [`strToPascalCase`](docs/utils.md#strtopascalcase) - PascalCase conversion
88
- - [`strToCamelCase`](docs/utils.md#strtocamelcase) - camelCase conversion
89
- - [`strToKebabCase`](docs/utils.md#strtokebabcase) - kebab-case conversion
90
- - [`strToSnakeCase`](docs/utils.md#strtosnakecase) - snake_case conversion
91
- - [`strIsNullOrEmpty`](docs/utils.md#strisnullorempty) - Check for undefined/null/empty (type guard)
92
- - [`strInsert`](docs/utils.md#strinsert) - Insert at position in string
93
-
94
- ### Number Utilities
95
-
96
- - [`numParseInt`](docs/utils.md#numparseint) - Parse string to integer
97
- - [`numParseFloat`](docs/utils.md#numparsefloat) - Parse string to float
98
- - [`numParseRoundedInt`](docs/utils.md#numparseroundedint) - Round float and return integer
99
- - [`numFormat`](docs/utils.md#numformat) - Thousands separator formatting
100
- - [`numIsNullOrEmpty`](docs/utils.md#numisnullorempty) - Check for undefined/null/0 (type guard)
101
-
102
- ### Date/Time Formatting
103
-
104
- - [`formatDate`](docs/utils.md#formatdate) - Convert date/time to formatted string
105
- - [`normalizeMonth`](docs/utils.md#normalizemonth) - Normalize year/month/day when setting month
106
- - [`convert12To24`](docs/utils.md#convert12to24) - Convert 12-hour to 24-hour format
107
-
108
- ### Byte Utilities
109
-
110
- - [`bytesConcat`](docs/utils.md#bytesconcat) - Concatenate multiple Uint8Arrays
111
- - [`bytesToHex`](docs/utils.md#bytestohex) - Convert Uint8Array to hex string
112
- - [`bytesFromHex`](docs/utils.md#bytesfromhex) - Convert hex string to Uint8Array
113
- - [`bytesToBase64`](docs/utils.md#bytestobase64) - Convert Uint8Array to base64 string
114
- - [`bytesFromBase64`](docs/utils.md#bytesfrombase64) - Convert base64 string to Uint8Array
115
-
116
- ### Async Wait
117
-
118
- - [`waitTime`](docs/utils.md#waittime) - Wait for specified time
119
- - [`waitUntil`](docs/utils.md#waituntil) - Wait until condition is true
120
-
121
- ### Worker Data Conversion
122
-
123
- - [`transferableEncode`](docs/utils.md#transferableencode) - Serialize custom types for Worker transfer
124
- - [`transferableDecode`](docs/utils.md#transferabledecode) - Deserialize Worker data to custom types
125
-
126
- ### Path Utilities
127
-
128
- - [`pathJoin`](docs/utils.md#pathjoin) - Combine paths (POSIX-style only)
129
- - [`pathBasename`](docs/utils.md#pathbasename) - Extract filename
130
- - [`pathExtname`](docs/utils.md#pathextname) - Extract extension
131
-
132
- ### Template Literal Tags
133
-
134
- - [`js`](docs/utils.md#js) - JavaScript code highlighting
135
- - [`ts`](docs/utils.md#ts) - TypeScript code highlighting
136
- - [`html`](docs/utils.md#html) - HTML markup highlighting
137
- - [`tsql`](docs/utils.md#tsql) - MSSQL T-SQL highlighting
138
- - [`mysql`](docs/utils.md#mysql) - MySQL SQL highlighting
139
- - [`pgsql`](docs/utils.md#pgsql) - PostgreSQL SQL highlighting
140
-
141
- ### Other Utilities
142
-
143
- - [`getPrimitiveTypeStr`](docs/utils.md#getprimitivetypestr) - Infer `PrimitiveTypeStr` from runtime value
144
- - [`env`](docs/utils.md#env) - Environment variable object
145
-
146
- ### Array Extensions
147
-
148
- #### Query
149
- - [`single`](docs/extensions.md#single) - Return single element (error if 2+)
150
- - [`first`](docs/extensions.md#first) - Return first element
151
- - [`last`](docs/extensions.md#last) - Return last element
152
-
153
- #### Filtering
154
- - [`filterExists`](docs/extensions.md#filterexists) - Remove `null`/`undefined`
155
- - [`ofType`](docs/extensions.md#oftype) - Filter by type
156
- - [`filterAsync`](docs/extensions.md#filterasync) - Async filter
157
-
158
- #### Mapping/Transformation
159
- - [`mapAsync`](docs/extensions.md#mapasync) - Async mapping (sequential)
160
- - [`mapMany`](docs/extensions.md#mapmany) - Flatten nested arrays and remove null/undefined
161
- - [`mapManyAsync`](docs/extensions.md#mapmanyasync) - Async mapMany
162
- - [`parallelAsync`](docs/extensions.md#parallelasync) - Parallel async mapping
163
-
164
- #### Grouping
165
- - [`groupBy`](docs/extensions.md#groupby) - Group by key
166
- - [`toMap`](docs/extensions.md#tomap) - Convert to Map
167
- - [`toMapAsync`](docs/extensions.md#tomapasync) - Async Map conversion
168
- - [`toArrayMap`](docs/extensions.md#toarraymap) - Convert to `Map<K, V[]>`
169
- - [`toSetMap`](docs/extensions.md#tosetmap) - Convert to `Map<K, Set<V>>`
170
- - [`toMapValues`](docs/extensions.md#tomapvalues) - Aggregate Map by group
171
- - [`toObject`](docs/extensions.md#toobject) - Convert to `Record<string, V>`
172
- - [`toTree`](docs/extensions.md#totree) - Convert to tree structure
173
-
174
- #### Deduplication
175
- - [`distinct`](docs/extensions.md#distinct) - Remove duplicates (new array)
176
- - [`distinctThis`](docs/extensions.md#distinctthis) - Remove duplicates (modify original)
177
-
178
- #### Sorting
179
- - [`orderBy`](docs/extensions.md#orderby) - Ascending sort (new array)
180
- - [`orderByDesc`](docs/extensions.md#orderbydesc) - Descending sort (new array)
181
- - [`orderByThis`](docs/extensions.md#orderbythis) - Ascending sort (modify original)
182
- - [`orderByDescThis`](docs/extensions.md#orderbydescthis) - Descending sort (modify original)
183
-
184
- #### Comparison/Merging
185
- - [`diffs`](docs/extensions.md#diffs) - Compare differences between arrays
186
- - [`oneWayDiffs`](docs/extensions.md#onewaydiffs) - One-way diff comparison
187
- - [`merge`](docs/extensions.md#merge) - Merge arrays
188
-
189
- #### Aggregation
190
- - [`sum`](docs/extensions.md#sum) - Sum
191
- - [`min`](docs/extensions.md#min) - Minimum
192
- - [`max`](docs/extensions.md#max) - Maximum
193
-
194
- #### Mutation
195
- - [`insert`](docs/extensions.md#insert) - Insert at specific position
196
- - [`remove`](docs/extensions.md#remove) - Remove item or items matching predicate
197
- - [`toggle`](docs/extensions.md#toggle) - Toggle item
198
- - [`clear`](docs/extensions.md#clear) - Remove all items
199
- - [`shuffle`](docs/extensions.md#shuffle) - Shuffle array
200
-
201
- ### Map Extensions
202
-
203
- - [`getOrCreate`](docs/extensions.md#getorcreate) - Get or create and return value
204
- - [`update`](docs/extensions.md#update) - Update value using function
205
-
206
- ### Set Extensions
207
-
208
- - [`adds`](docs/extensions.md#adds) - Add multiple values at once
209
- - [`toggle`](docs/extensions.md#toggle-1) - Toggle value (add/remove/force)
210
-
211
- ## Types
212
-
213
- - [`Bytes`](docs/types.md#bytes) - Alias for `Uint8Array`
214
- - [`PrimitiveTypeStr`](docs/types.md#primitivetypestr) - Primitive type string keys
215
- - [`PrimitiveTypeMap`](docs/types.md#primitivetypemap) - Mapping from type string to type
216
- - [`PrimitiveType`](docs/types.md#primitivetype) - Union of all primitive types (includes `undefined`)
217
- - [`DeepPartial`](docs/types.md#deeppartial) - Recursively convert properties to optional
218
- - [`Type`](docs/types.md#type) - Constructor type
219
- - [`ObjUndefToOptional`](docs/types.md#objundeftooptional) - Convert `undefined` properties to optional
220
- - [`ObjOptionalToUndef`](docs/types.md#objoptionaltoundef) - Convert optional properties to `required + undefined`
221
- - [`EqualOptions`](docs/types.md#equaloptions) - Options for `objEqual`
222
- - [`ObjMergeOptions`](docs/types.md#objmergeoptions) - Options for `objMerge`
223
- - [`ObjMerge3KeyOptions`](docs/types.md#objmerge3keyoptions) - Per-key options for `objMerge3`
224
- - [`DtNormalizedMonth`](docs/types.md#dtnormalizedmonth) - Return type of `normalizeMonth`
225
- - [`ZipArchiveProgress`](docs/types.md#ziparchiveprogress) - Progress info for `ZipArchive.extractAll`
226
- - [`ArrayDiffsResult`](docs/types.md#arraydiffsresult) - Result type of `Array.diffs()`
227
- - [`ArrayDiffs2Result`](docs/types.md#arraydiffs2result) - Result type of `Array.oneWayDiffs()`
228
- - [`TreeArray`](docs/types.md#treearray) - Result type of `Array.toTree()`
229
- - [`ComparableType`](docs/types.md#comparabletype) - Union of types usable for sorting/comparison
230
-
231
- ## Caveats
232
-
233
- ### Prototype Extension Conflicts
234
-
235
- This package extends Array, Map, and Set prototypes.
236
- Conflicts may occur when used with other libraries that extend the same method names.
237
- In case of conflict, the last defined implementation is applied based on load order.
238
-
239
- ### Timezone Handling
240
-
241
- When using `DateOnly.parse()`, `DateTime.parse()`:
242
- - `yyyy-MM-dd`, `yyyyMMdd` format: parse directly from string (no timezone influence)
243
- - ISO 8601 format (`2024-01-15T00:00:00Z`): interpret as UTC then convert to local
244
-
245
- When server and client timezones differ, actively use `yyyy-MM-dd` format.
246
-
247
- ### Memory Management (LazyGcMap)
248
-
249
- `LazyGcMap` has an internal GC timer, so it must be cleaned up.
250
-
251
- ```typescript
252
- // using statement (recommended)
253
- // gcInterval: GC execution interval (ms), expireTime: item expiration time (ms)
254
- using map = new LazyGcMap({ gcInterval: 10000, expireTime: 60000 }); // GC every 10 seconds, expire after 60 seconds
255
-
256
- // Or explicit dispose() call
257
- const map = new LazyGcMap({ gcInterval: 10000, expireTime: 60000 }); // GC every 10 seconds, expire after 60 seconds
258
- try {
259
- // ... use
260
- } finally {
261
- map.dispose();
262
- }
263
- ```
264
-
265
- ### jsonStringify's __type__ Reserved Word
266
-
267
- `jsonStringify`/`jsonParse` uses objects with `__type__` and `data` keys for type restoration.
268
- Be careful as user data in the form `{ __type__: "DateTime", data: "..." }` may be unintentionally type-converted.
269
-
270
- ### Circular References
271
-
272
- - `objClone`: supports circular references (tracked with WeakMap)
273
- - `jsonStringify`: throws TypeError on circular reference
274
- - `transferableEncode`: throws TypeError on circular reference (includes path information)
9
+ ## Source Index
10
+
11
+ ### (top-level)
12
+
13
+ | Source | Exports | Description | Test |
14
+ |--------|---------|-------------|------|
15
+ | `src/env.ts` | `env` | Runtime environment configuration object | - |
16
+ | `src/extensions/arr-ext.ts` | `ArrayDiffsResult`, `ArrayDiffs2Result`, `TreeArray`, `ComparableType` | Array diff, tree, and comparison utilities via prototype augmentation | `array-extension.spec.ts` |
17
+
18
+ ### errors
19
+
20
+ | Source | Exports | Description | Test |
21
+ |--------|---------|-------------|------|
22
+ | `src/errors/sd-error.ts` | `SdError` | Base error class with name-based error chain support | `errors.spec.ts` |
23
+ | `src/errors/argument-error.ts` | `ArgumentError` | Error thrown when a function receives an invalid argument | `errors.spec.ts` |
24
+ | `src/errors/not-implemented-error.ts` | `NotImplementedError` | Error indicating an unimplemented method or feature | `errors.spec.ts` |
25
+ | `src/errors/timeout-error.ts` | `TimeoutError` | Error thrown when an operation exceeds its time limit | `errors.spec.ts` |
26
+
27
+ ### types
28
+
29
+ | Source | Exports | Description | Test |
30
+ |--------|---------|-------------|------|
31
+ | `src/types/uuid.ts` | `Uuid` | UUID v4 generation and validation utility class | `uuid.spec.ts` |
32
+ | `src/types/lazy-gc-map.ts` | `LazyGcMap` | Map with lazy initialization and automatic garbage collection of unused entries | `lazy-gc-map.spec.ts` |
33
+ | `src/types/date-time.ts` | `DateTime` | Immutable date-time class with formatting, arithmetic, and comparison | `date-time.spec.ts` |
34
+ | `src/types/date-only.ts` | `DateOnly` | Immutable date-only class (year, month, day) without time component | `date-only.spec.ts` |
35
+ | `src/types/time.ts` | `Time` | Immutable time-of-day class (hour, minute, second) | `time.spec.ts` |
36
+
37
+ ### features
38
+
39
+ | Source | Exports | Description | Test |
40
+ |--------|---------|-------------|------|
41
+ | `src/features/debounce-queue.ts` | `DebounceQueue` | Queue that debounces rapid calls into a single delayed execution | `debounce-queue.spec.ts` |
42
+ | `src/features/serial-queue.ts` | `SerialQueue` | Queue that serializes async operations to run one at a time | `serial-queue.spec.ts` |
43
+ | `src/features/event-emitter.ts` | `EventEmitter` | Type-safe event emitter with on/off/emit pattern | `sd-event-emitter.spec.ts` |
44
+
45
+ ### utils
46
+
47
+ | Source | Exports | Description | Test |
48
+ |--------|---------|-------------|------|
49
+ | `src/utils/date-format.ts` | `DtNormalizedMonth`, `normalizeMonth`, `convert12To24`, `formatDate` | Date formatting and month normalization utilities | `date-format.spec.ts` |
50
+ | `src/utils/bytes.ts` | `bytesConcat`, `bytesToHex`, `bytesFromHex`, `bytesToBase64`, `bytesFromBase64` | Binary conversion utilities (hex, base64, concat) | `bytes-utils.spec.ts` |
51
+ | `src/utils/json.ts` | `jsonStringify`, `jsonParse` | JSON stringify/parse with custom type support (DateTime, DateOnly, etc.) | `json.spec.ts` |
52
+ | `src/utils/num.ts` | `numParseInt`, `numParseRoundedInt`, `numParseFloat`, `numIsNullOrEmpty`, `numFormat` | Number parsing and formatting utilities | `number.spec.ts` |
53
+ | `src/utils/obj.ts` | `objClone`, `EqualOptions`, `objEqual`, `ObjMergeOptions`, `objMerge`, `ObjMerge3KeyOptions`, `objMerge3`, `objOmit`, `objOmitByFilter`, `objPick`, `objGetChainValue`, `objGetChainValueByDepth`, `objSetChainValue`, `objDeleteChainValue`, `objClearUndefined`, `objClear`, `objNullToUndefined`, `objUnflatten`, `ObjUndefToOptional`, `ObjOptionalToUndef`, `objKeys`, `objEntries`, `objFromEntries`, `objMap` | Deep object utilities (clone, equal, merge, pick, omit, chain access) | `object.spec.ts` |
54
+ | `src/utils/primitive.ts` | `getPrimitiveTypeStr` | Primitive type string detection utility | `primitive.spec.ts` |
55
+ | `src/utils/str.ts` | `koreanGetSuffix`, `strReplaceFullWidth`, `strToPascalCase`, `strToCamelCase`, `strToKebabCase`, `strToSnakeCase`, `strIsNullOrEmpty`, `strInsert` | String utilities (case conversion, Korean suffix, full-width replacement) | `string.spec.ts` |
56
+ | `src/utils/template-strings.ts` | `js`, `ts`, `html`, `tsql`, `mysql`, `pgsql` | Tagged template literals for JS, TS, HTML, SQL syntax highlighting | `template-strings.spec.ts` |
57
+ | `src/utils/transferable.ts` | `transferableEncode`, `transferableDecode` | Encode/decode objects with Transferable types for structured clone | `transferable.spec.ts` |
58
+ | `src/utils/wait.ts` | `waitUntil`, `waitTime` | Async wait utilities (until condition, timed delay) | `wait.spec.ts` |
59
+ | `src/utils/xml.ts` | `xmlParse`, `xmlStringify` | XML parse and stringify utilities | `xml.spec.ts` |
60
+ | `src/utils/path.ts` | `pathJoin`, `pathBasename`, `pathExtname` | Platform-independent path join, basename, and extension utilities | `path.spec.ts` |
61
+ | `src/utils/error.ts` | `errorMessage` | Extract error message string from unknown error values | - |
62
+
63
+ ### zip
64
+
65
+ | Source | Exports | Description | Test |
66
+ |--------|---------|-------------|------|
67
+ | `src/zip/sd-zip.ts` | `ZipArchiveProgress`, `ZipArchive` | ZIP archive creation and extraction with progress callback | `sd-zip.spec.ts` |
68
+
69
+ ### type utilities
70
+
71
+ | Source | Exports | Description | Test |
72
+ |--------|---------|-------------|------|
73
+ | `src/common.types.ts` | `Bytes`, `PrimitiveTypeMap`, `PrimitiveTypeStr`, `PrimitiveType`, `DeepPartial`, `Type` | Common type utilities (Bytes, PrimitiveType, DeepPartial, Type) | - |
275
74
 
276
75
  ## License
277
76
 
@@ -3,12 +3,12 @@ import { DateOnly } from "./types/date-only";
3
3
  import { Time } from "./types/time";
4
4
  import { Uuid } from "./types/uuid";
5
5
  /**
6
- * Buffer 대신 사용하는 바이너리 타입
6
+ * Binary type used instead of Buffer
7
7
  */
8
8
  export type Bytes = Uint8Array;
9
9
  /**
10
- * Primitive 타입 매핑
11
- * orm-common과 공유
10
+ * Primitive type mapping
11
+ * Shared with orm-common
12
12
  */
13
13
  export type PrimitiveTypeMap = {
14
14
  string: string;
@@ -21,19 +21,19 @@ export type PrimitiveTypeMap = {
21
21
  Bytes: Bytes;
22
22
  };
23
23
  /**
24
- * Primitive 타입 문자열
24
+ * Primitive type string key
25
25
  */
26
26
  export type PrimitiveTypeStr = keyof PrimitiveTypeMap;
27
27
  /**
28
- * Primitive 타입 유니온
28
+ * Primitive type union
29
29
  */
30
30
  export type PrimitiveType = PrimitiveTypeMap[PrimitiveTypeStr] | undefined;
31
31
  /**
32
- * 깊은 Partial 타입
32
+ * Deep Partial type
33
33
  *
34
- * 객체의 모든 속성을 재귀적으로 선택적(optional)으로 만듭니다.
35
- * Primitive 타입(string, number, boolean ) 그대로 유지하고,
36
- * 객체/배열 타입만 재귀적으로 Partial 적용합니다.
34
+ * Recursively makes all properties of an object optional.
35
+ * Primitive types (string, number, boolean, etc.) are kept as-is,
36
+ * only object/array types have Partial applied recursively.
37
37
  *
38
38
  * @example
39
39
  * ```typescript
@@ -45,7 +45,7 @@ export type PrimitiveType = PrimitiveTypeMap[PrimitiveTypeStr] | undefined;
45
45
  * };
46
46
  * }
47
47
  *
48
- * // 모든 깊이의 속성이 선택적이
48
+ * // All properties at every depth become optional
49
49
  * const partial: DeepPartial<User> = {
50
50
  * profile: { address: {} }
51
51
  * };
@@ -55,10 +55,10 @@ export type DeepPartial<TObject> = Partial<{
55
55
  [K in keyof TObject]: TObject[K] extends PrimitiveType ? TObject[K] : DeepPartial<TObject[K]>;
56
56
  }>;
57
57
  /**
58
- * 생성자 타입
58
+ * Constructor type
59
59
  *
60
- * 클래스 생성자를 타입으로 표현할 사용합니다.
61
- * 주로 의존성 주입, 팩토리 패턴, instanceof 체크 등에서 활용됩니다.
60
+ * Used to represent a class constructor as a type.
61
+ * Primarily used in dependency injection, factory patterns, and instanceof checks.
62
62
  *
63
63
  * @example
64
64
  * function create<T>(ctor: Type<T>): T {
@@ -66,7 +66,7 @@ export type DeepPartial<TObject> = Partial<{
66
66
  * }
67
67
  *
68
68
  * class MyClass { name = "test"; }
69
- * const instance = create(MyClass); // MyClass 인스턴스
69
+ * const instance = create(MyClass); // MyClass instance
70
70
  */
71
71
  export interface Type<TInstance> extends Function {
72
72
  new (...args: unknown[]): TInstance;
@@ -1,24 +1,24 @@
1
1
  import { SdError } from "./sd-error";
2
2
  /**
3
- * 인수 오류
3
+ * Argument error
4
4
  *
5
- * 잘못된 인수를 받았을 발생시키는 에러이다.
6
- * 인수 객체를 YAML 형식으로 메시지에 포함하여 디버깅을 용이하게 한다.
5
+ * An error thrown when invalid arguments are received.
6
+ * Includes the argument object in YAML format in the message to facilitate debugging.
7
7
  *
8
8
  * @example
9
- * // 인수 객체만 전달
9
+ * // Passing only the argument object
10
10
  * throw new ArgumentError({ userId: 123, name: null });
11
- * // 결과 메시지: "인수가 잘못되었습니다.\n\nuserId: 123\nname: null"
11
+ * // Result message: "Invalid arguments.\n\nuserId: 123\nname: null"
12
12
  *
13
13
  * @example
14
- * // 커스텀 메시지와 인수 객체 전달
15
- * throw new ArgumentError("유효하지 않은 사용자", { userId: 123 });
16
- * // 결과 메시지: "유효하지 않은 사용자\n\nuserId: 123"
14
+ * // Passing a custom message and argument object
15
+ * throw new ArgumentError("Invalid user", { userId: 123 });
16
+ * // Result message: "Invalid user\n\nuserId: 123"
17
17
  */
18
18
  export declare class ArgumentError extends SdError {
19
- /** 기본 메시지("인수가 잘못되었습니다.")와 함께 인수 객체를 YAML 형식으로 출력 */
19
+ /** Output argument object in YAML format with default message ("Invalid arguments.") */
20
20
  constructor(argObj: Record<string, unknown>);
21
- /** 커스텀 메시지와 함께 인수 객체를 YAML 형식으로 출력 */
21
+ /** Output argument object in YAML format with a custom message */
22
22
  constructor(message: string, argObj: Record<string, unknown>);
23
23
  constructor(arg1: Record<string, unknown> | string, arg2?: Record<string, unknown>);
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"argument-error.d.ts","sourceRoot":"","sources":["../../src/errors/argument-error.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,qDAAqD;gBACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3C,sCAAsC;gBAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAYnF"}
1
+ {"version":3,"file":"argument-error.d.ts","sourceRoot":"","sources":["../../src/errors/argument-error.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,wFAAwF;gBAC5E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3C,kEAAkE;gBACtD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAYnF"}
@@ -5,9 +5,9 @@ class ArgumentError extends SdError {
5
5
  const message = typeof arg1 === "string" ? arg1 : void 0;
6
6
  const argObj = typeof arg1 === "string" ? arg2 : arg1;
7
7
  if (argObj != null) {
8
- super((message ?? "\uC778\uC218\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4.") + "\n\n" + YAML.stringify(argObj));
8
+ super((message ?? "Invalid arguments.") + "\n\n" + YAML.stringify(argObj));
9
9
  } else {
10
- super(message ?? "\uC778\uC218\uAC00 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
10
+ super(message ?? "Invalid arguments.");
11
11
  }
12
12
  this.name = "ArgumentError";
13
13
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/argument-error.ts"],
4
- "mappings": "AAGA,OAAO,UAAU;AACjB,SAAS,eAAe;AAkBjB,MAAM,sBAAsB,QAAQ;AAAA,EAMzC,YAAY,MAAwC,MAAgC;AAClF,UAAM,UAAU,OAAO,SAAS,WAAW,OAAO;AAClD,UAAM,SAAS,OAAO,SAAS,WAAW,OAAO;AAEjD,QAAI,UAAU,MAAM;AAClB,aAAO,WAAW,oEAAkB,SAAS,KAAK,UAAU,MAAM,CAAC;AAAA,IACrE,OAAO;AACL,YAAM,WAAW,gEAAc;AAAA,IACjC;AACA,SAAK,OAAO;AAAA,EACd;AACF;",
4
+ "mappings": "AAGA,OAAO,UAAU;AACjB,SAAS,eAAe;AAkBjB,MAAM,sBAAsB,QAAQ;AAAA,EAMzC,YAAY,MAAwC,MAAgC;AAClF,UAAM,UAAU,OAAO,SAAS,WAAW,OAAO;AAClD,UAAM,SAAS,OAAO,SAAS,WAAW,OAAO;AAEjD,QAAI,UAAU,MAAM;AAClB,aAAO,WAAW,wBAAwB,SAAS,KAAK,UAAU,MAAM,CAAC;AAAA,IAC3E,OAAO;AACL,YAAM,WAAW,oBAAoB;AAAA,IACvC;AACA,SAAK,OAAO;AAAA,EACd;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,28 +1,28 @@
1
1
  import { SdError } from "./sd-error";
2
2
  /**
3
- * 미구현 오류
3
+ * Not implemented error
4
4
  *
5
- * 아직 구현되지 않은 기능을 호출했을 발생시키는 에러이다.
6
- * 추상 메서드 스텁, 향후 구현 예정인 분기 등에 사용한다.
5
+ * An error thrown when a feature that has not yet been implemented is called.
6
+ * Used for abstract method stubs, branches planned for future implementation, etc.
7
7
  *
8
8
  * @example
9
- * // 추상 메서드 구현
9
+ * // Before abstract method implementation
10
10
  * class BaseService {
11
11
  * process(): void {
12
- * throw new NotImplementedError("서브클래스에서 구현 필요");
12
+ * throw new NotImplementedError("Implementation required in subclass");
13
13
  * }
14
14
  * }
15
15
  *
16
16
  * @example
17
- * // 향후 구현 예정 분기
17
+ * // Branch planned for future implementation
18
18
  * switch (type) {
19
19
  * case "A": return handleA();
20
- * case "B": throw new NotImplementedError(`타입 ${type} 처리`);
20
+ * case "B": throw new NotImplementedError(`Handling for type ${type}`);
21
21
  * }
22
22
  */
23
23
  export declare class NotImplementedError extends SdError {
24
24
  /**
25
- * @param message 추가 설명 메시지
25
+ * @param message Additional description message
26
26
  */
27
27
  constructor(message?: string);
28
28
  }
@@ -1,10 +1,10 @@
1
1
  import { SdError } from "./sd-error.js";
2
2
  class NotImplementedError extends SdError {
3
3
  /**
4
- * @param message 추가 설명 메시지
4
+ * @param message Additional description message
5
5
  */
6
6
  constructor(message) {
7
- super("\uAD6C\uD604\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4" + (message != null ? ": " + message : ""));
7
+ super("Not implemented" + (message != null ? ": " + message : ""));
8
8
  this.name = "NotImplementedError";
9
9
  }
10
10
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/not-implemented-error.ts"],
4
- "mappings": "AAAA,SAAS,eAAe;AAuBjB,MAAM,4BAA4B,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI/C,YAAY,SAAkB;AAC5B,UAAM,oEAAkB,WAAW,OAAO,OAAO,UAAU,GAAG;AAC9D,SAAK,OAAO;AAAA,EACd;AACF;",
4
+ "mappings": "AAAA,SAAS,eAAe;AAuBjB,MAAM,4BAA4B,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI/C,YAAY,SAAkB;AAC5B,UAAM,qBAAqB,WAAW,OAAO,OAAO,UAAU,GAAG;AACjE,SAAK,OAAO;AAAA,EACd;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,26 +1,26 @@
1
1
  /**
2
- * 오류의 Tree 구조 구성이 가능한 오류 클래스
3
- * ES2024 cause 속성 활용
2
+ * Error class supporting Tree structure composition
3
+ * Utilizes ES2024 cause property
4
4
  *
5
5
  * @example
6
- * // 원인 에러를 감싸서 생성
6
+ * // Wrap a cause error
7
7
  * try {
8
8
  * await fetch(url);
9
9
  * } catch (err) {
10
- * throw new SdError(err, "API 호출 실패", "사용자 로드 실패");
10
+ * throw new SdError(err, "API call failed", "User load failed");
11
11
  * }
12
- * // 결과 메시지: "사용자 로드 실패 => API 호출 실패 => 원본 에러 메시지"
12
+ * // Result message: "User load failed => API call failed => original error message"
13
13
  *
14
14
  * @example
15
- * // 메시지만으로 생성
16
- * throw new SdError("잘못된 상태", "처리 불가");
17
- * // 결과 메시지: "처리 불가 => 잘못된 상태"
15
+ * // Create with message only
16
+ * throw new SdError("invalid state", "processing not possible");
17
+ * // Result message: "processing not possible => invalid state"
18
18
  */
19
19
  export declare class SdError extends Error {
20
20
  cause?: Error;
21
- /** 원인 에러를 감싸서 생성. 메시지는 역순으로 연결됨 (상위 메시지 => 하위 메시지 => 원인 메시지) */
21
+ /** Create by wrapping a cause error. Messages are joined in reverse order (upper message => lower message => cause message) */
22
22
  constructor(cause: Error, ...messages: string[]);
23
- /** 메시지만으로 생성. 메시지는 역순으로 연결됨 (상위 메시지 => 하위 메시지) */
23
+ /** Create with messages only. Messages are joined in reverse order (upper message => lower message) */
24
24
  constructor(...messages: string[]);
25
25
  constructor(arg1?: unknown, ...messages: string[]);
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sd-error.d.ts","sourceRoot":"","sources":["../../src/errors/sd-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IAEvB,gEAAgE;gBACpD,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE;IAC/C,kDAAkD;gBACtC,GAAG,QAAQ,EAAE,MAAM,EAAE;gBACrB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE;CAoClD"}
1
+ {"version":3,"file":"sd-error.d.ts","sourceRoot":"","sources":["../../src/errors/sd-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IAEvB,+HAA+H;gBACnH,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE;IAC/C,uGAAuG;gBAC3F,GAAG,QAAQ,EAAE,MAAM,EAAE;gBACrB,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE;CAoClD"}