@simplysm/core-common 14.0.23 → 14.0.25
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.
- package/package.json +2 -3
- package/README.md +0 -218
- package/docs/array-extensions.md +0 -399
- package/docs/env.md +0 -33
- package/docs/errors.md +0 -68
- package/docs/features.md +0 -112
- package/docs/map-extensions.md +0 -41
- package/docs/set-extensions.md +0 -38
- package/docs/template-strings-and-zip.md +0 -87
- package/docs/type-utilities.md +0 -75
- package/docs/types.md +0 -307
- package/docs/utilities.md +0 -723
package/docs/types.md
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
# Types
|
|
2
|
-
|
|
3
|
-
## `Uuid`
|
|
4
|
-
|
|
5
|
-
UUID v4 class. Generates cryptographically secure UUIDs using `crypto.getRandomValues`.
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
class Uuid {
|
|
9
|
-
static generate(): Uuid;
|
|
10
|
-
static fromBytes(bytes: Bytes): Uuid;
|
|
11
|
-
|
|
12
|
-
constructor(uuid: string);
|
|
13
|
-
|
|
14
|
-
toString(): string;
|
|
15
|
-
toBytes(): Bytes;
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Static Methods
|
|
20
|
-
|
|
21
|
-
| Method | Description |
|
|
22
|
-
|--------|-------------|
|
|
23
|
-
| `generate()` | Create a new random UUID v4 instance |
|
|
24
|
-
| `fromBytes(bytes)` | Create UUID from a 16-byte `Uint8Array`. Throws `ArgumentError` if length is not 16. |
|
|
25
|
-
|
|
26
|
-
### Instance Methods
|
|
27
|
-
|
|
28
|
-
| Method | Returns | Description |
|
|
29
|
-
|--------|---------|-------------|
|
|
30
|
-
| `toString()` | `string` | UUID string in `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` format |
|
|
31
|
-
| `toBytes()` | `Bytes` | 16-byte `Uint8Array` representation |
|
|
32
|
-
|
|
33
|
-
### Constructor
|
|
34
|
-
|
|
35
|
-
| Parameter | Type | Description |
|
|
36
|
-
|-----------|------|-------------|
|
|
37
|
-
| `uuid` | `string` | UUID string. Must match format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. Throws `ArgumentError` if invalid. |
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## `LazyGcMap<TKey, TValue>`
|
|
42
|
-
|
|
43
|
-
Auto-expiring Map with LRU-style access tracking. Items are automatically deleted after the configured expire time if not accessed. Must be disposed after use to stop the GC timer.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
class LazyGcMap<TKey, TValue> {
|
|
47
|
-
constructor(options: {
|
|
48
|
-
gcInterval?: number;
|
|
49
|
-
expireTime: number;
|
|
50
|
-
onExpire?: (key: TKey, value: TValue) => void | Promise<void>;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
get size(): number;
|
|
54
|
-
has(key: TKey): boolean;
|
|
55
|
-
get(key: TKey): TValue | undefined;
|
|
56
|
-
set(key: TKey, value: TValue): void;
|
|
57
|
-
delete(key: TKey): boolean;
|
|
58
|
-
clear(): void;
|
|
59
|
-
getOrCreate(key: TKey, factory: () => TValue): TValue;
|
|
60
|
-
values(): IterableIterator<TValue>;
|
|
61
|
-
keys(): IterableIterator<TKey>;
|
|
62
|
-
entries(): IterableIterator<[TKey, TValue]>;
|
|
63
|
-
dispose(): void;
|
|
64
|
-
[Symbol.dispose](): void;
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Constructor Options
|
|
69
|
-
|
|
70
|
-
| Option | Type | Description |
|
|
71
|
-
|--------|------|-------------|
|
|
72
|
-
| `gcInterval` | `number \| undefined` | GC check interval in ms. Default: `expireTime / 10` (min 1000ms). |
|
|
73
|
-
| `expireTime` | `number` | Time in ms after last access before an item is expired. |
|
|
74
|
-
| `onExpire` | `(key, value) => void \| Promise<void>` | Callback invoked when an item expires. Errors are logged, not thrown. |
|
|
75
|
-
|
|
76
|
-
### Methods
|
|
77
|
-
|
|
78
|
-
| Method | Returns | Description |
|
|
79
|
-
|--------|---------|-------------|
|
|
80
|
-
| `size` | `number` | Number of stored items |
|
|
81
|
-
| `has(key)` | `boolean` | Check if key exists (does not refresh access time) |
|
|
82
|
-
| `get(key)` | `TValue \| undefined` | Get value and refresh access time (LRU) |
|
|
83
|
-
| `set(key, value)` | `void` | Store value and start GC timer if needed |
|
|
84
|
-
| `delete(key)` | `boolean` | Remove item. Stops GC timer if map becomes empty. |
|
|
85
|
-
| `clear()` | `void` | Remove all items (instance remains usable) |
|
|
86
|
-
| `getOrCreate(key, factory)` | `TValue` | Get existing value or create via factory, store, and return. Throws if disposed. |
|
|
87
|
-
| `values()` | `IterableIterator<TValue>` | Iterate over values |
|
|
88
|
-
| `keys()` | `IterableIterator<TKey>` | Iterate over keys |
|
|
89
|
-
| `entries()` | `IterableIterator<[TKey, TValue]>` | Iterate over [key, value] pairs |
|
|
90
|
-
| `dispose()` | `void` | Stop GC timer and clear all data |
|
|
91
|
-
| `[Symbol.dispose]()` | `void` | Supports `using` statement |
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## `DateTime`
|
|
96
|
-
|
|
97
|
-
Immutable date-time class wrapping JavaScript `Date`. Provides millisecond precision and local timezone operation.
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
class DateTime {
|
|
101
|
-
readonly date: Date;
|
|
102
|
-
|
|
103
|
-
constructor();
|
|
104
|
-
constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
|
|
105
|
-
constructor(tick: number);
|
|
106
|
-
constructor(date: Date);
|
|
107
|
-
|
|
108
|
-
static parse(str: string): DateTime;
|
|
109
|
-
|
|
110
|
-
// Getters
|
|
111
|
-
get year(): number;
|
|
112
|
-
get month(): number;
|
|
113
|
-
get day(): number;
|
|
114
|
-
get hour(): number;
|
|
115
|
-
get minute(): number;
|
|
116
|
-
get second(): number;
|
|
117
|
-
get millisecond(): number;
|
|
118
|
-
get tick(): number;
|
|
119
|
-
get dayOfWeek(): number;
|
|
120
|
-
get timezoneOffsetMinutes(): number;
|
|
121
|
-
get isValid(): boolean;
|
|
122
|
-
|
|
123
|
-
// Immutable setters (return new instance)
|
|
124
|
-
setYear(year: number): DateTime;
|
|
125
|
-
setMonth(month: number): DateTime;
|
|
126
|
-
setDay(day: number): DateTime;
|
|
127
|
-
setHour(hour: number): DateTime;
|
|
128
|
-
setMinute(minute: number): DateTime;
|
|
129
|
-
setSecond(second: number): DateTime;
|
|
130
|
-
setMillisecond(millisecond: number): DateTime;
|
|
131
|
-
|
|
132
|
-
// Arithmetic (return new instance)
|
|
133
|
-
addYears(years: number): DateTime;
|
|
134
|
-
addMonths(months: number): DateTime;
|
|
135
|
-
addDays(days: number): DateTime;
|
|
136
|
-
addHours(hours: number): DateTime;
|
|
137
|
-
addMinutes(minutes: number): DateTime;
|
|
138
|
-
addSeconds(seconds: number): DateTime;
|
|
139
|
-
addMilliseconds(milliseconds: number): DateTime;
|
|
140
|
-
|
|
141
|
-
// Formatting
|
|
142
|
-
toFormatString(formatStr: string): string;
|
|
143
|
-
toString(): string;
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Static Methods
|
|
148
|
-
|
|
149
|
-
| Method | Description |
|
|
150
|
-
|--------|-------------|
|
|
151
|
-
| `parse(str)` | Parse string to DateTime. Supported formats: `yyyy-MM-dd HH:mm:ss`, `yyyy-MM-dd HH:mm:ss.fff`, `yyyyMMddHHmmss`, `yyyy-MM-dd AM/PM HH:mm:ss`, ISO 8601. Throws `ArgumentError` on failure. |
|
|
152
|
-
|
|
153
|
-
### Getters
|
|
154
|
-
|
|
155
|
-
| Property | Type | Description |
|
|
156
|
-
|----------|------|-------------|
|
|
157
|
-
| `year` | `number` | Full year |
|
|
158
|
-
| `month` | `number` | Month (1-12) |
|
|
159
|
-
| `day` | `number` | Day of month (1-31) |
|
|
160
|
-
| `hour` | `number` | Hour (0-23) |
|
|
161
|
-
| `minute` | `number` | Minute (0-59) |
|
|
162
|
-
| `second` | `number` | Second (0-59) |
|
|
163
|
-
| `millisecond` | `number` | Millisecond (0-999) |
|
|
164
|
-
| `tick` | `number` | Milliseconds since epoch |
|
|
165
|
-
| `dayOfWeek` | `number` | Day of week (0=Sunday, 6=Saturday) |
|
|
166
|
-
| `timezoneOffsetMinutes` | `number` | Local timezone offset in minutes (e.g., +540 for KST) |
|
|
167
|
-
| `isValid` | `boolean` | Whether the date is valid |
|
|
168
|
-
|
|
169
|
-
### Formatting
|
|
170
|
-
|
|
171
|
-
`toFormatString(formatStr)` uses C#-style format patterns. See `dt.format` in [utilities.md](./utilities.md) for the full pattern table.
|
|
172
|
-
|
|
173
|
-
`toString()` returns `"yyyy-MM-ddTHH:mm:ss.fffzzz"`.
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## `DateOnly`
|
|
178
|
-
|
|
179
|
-
Immutable date-only class (no time component). Local timezone based.
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
class DateOnly {
|
|
183
|
-
readonly date: Date;
|
|
184
|
-
|
|
185
|
-
constructor();
|
|
186
|
-
constructor(year: number, month: number, day: number);
|
|
187
|
-
constructor(tick: number);
|
|
188
|
-
constructor(date: Date);
|
|
189
|
-
|
|
190
|
-
static parse(str: string): DateOnly;
|
|
191
|
-
static getDateByYearWeekSeq(
|
|
192
|
-
arg: { year: number; month?: number; weekSeq: number },
|
|
193
|
-
weekStartDay?: number,
|
|
194
|
-
minDaysInFirstWeek?: number,
|
|
195
|
-
): DateOnly;
|
|
196
|
-
|
|
197
|
-
// Getters
|
|
198
|
-
get year(): number;
|
|
199
|
-
get month(): number;
|
|
200
|
-
get day(): number;
|
|
201
|
-
get tick(): number;
|
|
202
|
-
get dayOfWeek(): number;
|
|
203
|
-
get isValid(): boolean;
|
|
204
|
-
|
|
205
|
-
// Immutable setters
|
|
206
|
-
setYear(year: number): DateOnly;
|
|
207
|
-
setMonth(month: number): DateOnly;
|
|
208
|
-
setDay(day: number): DateOnly;
|
|
209
|
-
|
|
210
|
-
// Arithmetic
|
|
211
|
-
addYears(years: number): DateOnly;
|
|
212
|
-
addMonths(months: number): DateOnly;
|
|
213
|
-
addDays(days: number): DateOnly;
|
|
214
|
-
|
|
215
|
-
// Week sequence
|
|
216
|
-
getBaseYearMonthSeqForWeekSeq(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; monthSeq: number };
|
|
217
|
-
getWeekSeqStartDate(weekStartDay?: number, minDaysInFirstWeek?: number): DateOnly;
|
|
218
|
-
getWeekSeqOfYear(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; weekSeq: number };
|
|
219
|
-
getWeekSeqOfMonth(weekStartDay?: number, minDaysInFirstWeek?: number): { year: number; monthSeq: number; weekSeq: number };
|
|
220
|
-
|
|
221
|
-
// Formatting
|
|
222
|
-
toFormatString(formatStr: string): string;
|
|
223
|
-
toString(): string;
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Static Methods
|
|
228
|
-
|
|
229
|
-
| Method | Description |
|
|
230
|
-
|--------|-------------|
|
|
231
|
-
| `parse(str)` | Parse string to DateOnly. Supported formats: `yyyy-MM-dd`, `yyyyMMdd`, ISO 8601. Throws `ArgumentError` on failure. |
|
|
232
|
-
| `getDateByYearWeekSeq(arg, weekStartDay?, minDaysInFirstWeek?)` | Get the start date of a given week number within a year or month. |
|
|
233
|
-
|
|
234
|
-
### Week Sequence Methods
|
|
235
|
-
|
|
236
|
-
All week methods accept optional parameters:
|
|
237
|
-
- `weekStartDay`: 0=Sunday, 1=Monday (default), ..., 6=Saturday
|
|
238
|
-
- `minDaysInFirstWeek`: Minimum days for first week (default: 4, ISO 8601)
|
|
239
|
-
|
|
240
|
-
| Method | Returns | Description |
|
|
241
|
-
|--------|---------|-------------|
|
|
242
|
-
| `getBaseYearMonthSeqForWeekSeq(...)` | `{ year, monthSeq }` | Base year and month for this date's week |
|
|
243
|
-
| `getWeekSeqStartDate(...)` | `DateOnly` | Start date of this date's week |
|
|
244
|
-
| `getWeekSeqOfYear(...)` | `{ year, weekSeq }` | Year and week number within that year |
|
|
245
|
-
| `getWeekSeqOfMonth(...)` | `{ year, monthSeq, weekSeq }` | Year, month, and week number within that month |
|
|
246
|
-
|
|
247
|
-
`toString()` returns `"yyyy-MM-dd"`.
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## `Time`
|
|
252
|
-
|
|
253
|
-
Immutable time-only class (no date component). Values wrap around 24 hours. Negative values are normalized.
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
class Time {
|
|
257
|
-
constructor();
|
|
258
|
-
constructor(hour: number, minute: number, second?: number, millisecond?: number);
|
|
259
|
-
constructor(tick: number);
|
|
260
|
-
constructor(date: Date);
|
|
261
|
-
|
|
262
|
-
static parse(str: string): Time;
|
|
263
|
-
|
|
264
|
-
// Getters
|
|
265
|
-
get hour(): number;
|
|
266
|
-
get minute(): number;
|
|
267
|
-
get second(): number;
|
|
268
|
-
get millisecond(): number;
|
|
269
|
-
get tick(): number;
|
|
270
|
-
get isValid(): boolean;
|
|
271
|
-
|
|
272
|
-
// Immutable setters
|
|
273
|
-
setHour(hour: number): Time;
|
|
274
|
-
setMinute(minute: number): Time;
|
|
275
|
-
setSecond(second: number): Time;
|
|
276
|
-
setMillisecond(millisecond: number): Time;
|
|
277
|
-
|
|
278
|
-
// Arithmetic (24-hour wrapping)
|
|
279
|
-
addHours(hours: number): Time;
|
|
280
|
-
addMinutes(minutes: number): Time;
|
|
281
|
-
addSeconds(seconds: number): Time;
|
|
282
|
-
addMilliseconds(milliseconds: number): Time;
|
|
283
|
-
|
|
284
|
-
// Formatting
|
|
285
|
-
toFormatString(formatStr: string): string;
|
|
286
|
-
toString(): string;
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### Static Methods
|
|
291
|
-
|
|
292
|
-
| Method | Description |
|
|
293
|
-
|--------|-------------|
|
|
294
|
-
| `parse(str)` | Parse string to Time. Supported formats: `HH:mm:ss`, `HH:mm:ss.fff`, `AM/PM HH:mm:ss`, ISO 8601 (time part extracted). Throws `ArgumentError` on failure. |
|
|
295
|
-
|
|
296
|
-
### Getters
|
|
297
|
-
|
|
298
|
-
| Property | Type | Description |
|
|
299
|
-
|----------|------|-------------|
|
|
300
|
-
| `hour` | `number` | Hour (0-23) |
|
|
301
|
-
| `minute` | `number` | Minute (0-59) |
|
|
302
|
-
| `second` | `number` | Second (0-59) |
|
|
303
|
-
| `millisecond` | `number` | Millisecond (0-999) |
|
|
304
|
-
| `tick` | `number` | Total milliseconds from midnight (0 to 86399999) |
|
|
305
|
-
| `isValid` | `boolean` | Whether the time is valid |
|
|
306
|
-
|
|
307
|
-
`toString()` returns `"HH:mm:ss.fff"`.
|