@simplysm/core-common 13.0.98 → 13.0.99
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/README.md +6 -6
- package/docs/features.md +1 -1
- package/docs/types.md +1 -1
- package/docs/utils.md +52 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @simplysm/core-common
|
|
2
2
|
|
|
3
|
-
Core module (common)
|
|
3
|
+
Core module (common) -- platform-neutral core utilities for the Simplysm framework.
|
|
4
4
|
|
|
5
5
|
Provides error classes, immutable date/time types, prototype extensions, event handling, and utility namespaces that work in both browser and Node.js environments.
|
|
6
6
|
|
|
@@ -14,9 +14,9 @@ npm install @simplysm/core-common
|
|
|
14
14
|
|
|
15
15
|
Importing the package entry point (`@simplysm/core-common`) automatically patches `Array`, `Map`, and `Set` prototypes with extension methods. These are declared as side effects in `package.json`:
|
|
16
16
|
|
|
17
|
-
- `extensions/arr-ext`
|
|
18
|
-
- `extensions/map-ext`
|
|
19
|
-
- `extensions/set-ext`
|
|
17
|
+
- `extensions/arr-ext` -- Array prototype extensions
|
|
18
|
+
- `extensions/map-ext` -- Map prototype extensions
|
|
19
|
+
- `extensions/set-ext` -- Set prototype extensions
|
|
20
20
|
|
|
21
21
|
If you import only specific modules (e.g., `@simplysm/core-common/dist/types/date-time`), the prototype extensions are **not** applied unless you also import the entry point or the extension modules directly.
|
|
22
22
|
|
|
@@ -57,7 +57,7 @@ If you import only specific modules (e.g., `@simplysm/core-common/dist/types/dat
|
|
|
57
57
|
| API | Type | Description |
|
|
58
58
|
|-----|------|-------------|
|
|
59
59
|
| `EventEmitter` | class | Type-safe event emitter (EventTarget wrapper) |
|
|
60
|
-
| `DebounceQueue` | class | Async debounce
|
|
60
|
+
| `DebounceQueue` | class | Async debounce -- only the last call executes |
|
|
61
61
|
| `SerialQueue` | class | Async serial execution queue |
|
|
62
62
|
|
|
63
63
|
-> See [docs/features.md](./docs/features.md) for details.
|
|
@@ -66,7 +66,7 @@ If you import only specific modules (e.g., `@simplysm/core-common/dist/types/dat
|
|
|
66
66
|
|
|
67
67
|
| API | Type | Description |
|
|
68
68
|
|-----|------|-------------|
|
|
69
|
-
| `Array` extensions | prototype | 34 methods
|
|
69
|
+
| `Array` extensions | prototype | 34 methods -- query, transform, diff, sort, mutate |
|
|
70
70
|
| `Map` extensions | prototype | `getOrCreate`, `update` |
|
|
71
71
|
| `Set` extensions | prototype | `adds`, `toggle` |
|
|
72
72
|
|
package/docs/features.md
CHANGED
|
@@ -129,7 +129,7 @@ export class SerialQueue extends EventEmitter<{ error: SdError }> {
|
|
|
129
129
|
}
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
**Error handling:** Same as `DebounceQueue`
|
|
132
|
+
**Error handling:** Same as `DebounceQueue` -- emitted as event if listeners exist, otherwise logged.
|
|
133
133
|
|
|
134
134
|
**Example:**
|
|
135
135
|
|
package/docs/types.md
CHANGED
|
@@ -57,7 +57,7 @@ export class DateTime {
|
|
|
57
57
|
/**
|
|
58
58
|
* Parse a string to create DateTime instance
|
|
59
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', ISO 8601
|
|
60
|
+
* 'yyyy-MM-dd AM/PM HH:mm:ss', Korean AM/PM (오전/오후), ISO 8601
|
|
61
61
|
* @throws ArgumentError If unsupported format
|
|
62
62
|
*/
|
|
63
63
|
static parse(str: string): DateTime;
|
package/docs/utils.md
CHANGED
|
@@ -26,9 +26,13 @@ Deep equality comparison. Supports DateTime, DateOnly, Time, Uuid, Date, RegExp,
|
|
|
26
26
|
export function equal(source: unknown, target: unknown, options?: EqualOptions): boolean;
|
|
27
27
|
|
|
28
28
|
export interface EqualOptions {
|
|
29
|
+
/** List of keys to compare (applies only to top level) */
|
|
29
30
|
topLevelIncludes?: string[];
|
|
31
|
+
/** List of keys to exclude from comparison (applies only to top level) */
|
|
30
32
|
topLevelExcludes?: string[];
|
|
33
|
+
/** Whether to ignore array order. O(n^2) complexity when true */
|
|
31
34
|
ignoreArrayIndex?: boolean;
|
|
35
|
+
/** Whether to do shallow comparison. Only compare 1 level (reference comparison) when true */
|
|
32
36
|
shallow?: boolean;
|
|
33
37
|
}
|
|
34
38
|
```
|
|
@@ -45,7 +49,9 @@ export function merge<TSource, TMergeTarget>(
|
|
|
45
49
|
): TSource & TMergeTarget;
|
|
46
50
|
|
|
47
51
|
export interface MergeOptions {
|
|
52
|
+
/** Array processing method. "replace": replace with target (default), "concat": merge (deduplicate) */
|
|
48
53
|
arrayProcess?: "replace" | "concat";
|
|
54
|
+
/** Whether to delete the key when target is null */
|
|
49
55
|
useDelTargetNull?: boolean;
|
|
50
56
|
}
|
|
51
57
|
```
|
|
@@ -67,8 +73,11 @@ export function merge3<
|
|
|
67
73
|
): { conflict: boolean; result: O & S & T };
|
|
68
74
|
|
|
69
75
|
export interface Merge3KeyOptions {
|
|
76
|
+
/** List of sub-keys to compare (same as equal's topLevelIncludes) */
|
|
70
77
|
keys?: string[];
|
|
78
|
+
/** List of sub-keys to exclude from comparison */
|
|
71
79
|
excludes?: string[];
|
|
80
|
+
/** Whether to ignore array order */
|
|
72
81
|
ignoreArrayIndex?: boolean;
|
|
73
82
|
}
|
|
74
83
|
```
|
|
@@ -203,11 +212,32 @@ export function map<TSource extends object, TNewKey extends string, TNewValue>(
|
|
|
203
212
|
): Record<TNewKey | Extract<keyof TSource, string>, TNewValue>;
|
|
204
213
|
```
|
|
205
214
|
|
|
215
|
+
**Example:**
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
const colors = { primary: "255, 0, 0", secondary: "0, 255, 0" };
|
|
219
|
+
|
|
220
|
+
// Transform only values (pass null for key to keep original)
|
|
221
|
+
obj.map(colors, (key, rgb) => [null, `rgb(${rgb})`]);
|
|
222
|
+
// { primary: "rgb(255, 0, 0)", secondary: "rgb(0, 255, 0)" }
|
|
223
|
+
|
|
224
|
+
// Transform both keys and values
|
|
225
|
+
obj.map(colors, (key, rgb) => [`${key}Light`, `rgb(${rgb})`]);
|
|
226
|
+
// { primaryLight: "rgb(255, 0, 0)", secondaryLight: "rgb(0, 255, 0)" }
|
|
227
|
+
```
|
|
228
|
+
|
|
206
229
|
### Type utilities from `obj`
|
|
207
230
|
|
|
208
231
|
```typescript
|
|
209
|
-
|
|
210
|
-
export type
|
|
232
|
+
/** Convert properties with undefined to optional */
|
|
233
|
+
export type UndefToOptional<TObject> = {
|
|
234
|
+
[K in keyof TObject as undefined extends TObject[K] ? K : never]?: TObject[K];
|
|
235
|
+
} & { [K in keyof TObject as undefined extends TObject[K] ? never : K]: TObject[K] };
|
|
236
|
+
|
|
237
|
+
/** Convert optional properties to required + undefined union */
|
|
238
|
+
export type OptionalToUndef<TObject> = {
|
|
239
|
+
[K in keyof TObject]-?: {} extends Pick<TObject, K> ? TObject[K] | undefined : TObject[K];
|
|
240
|
+
};
|
|
211
241
|
```
|
|
212
242
|
|
|
213
243
|
---
|
|
@@ -227,6 +257,16 @@ export function getKoreanSuffix(
|
|
|
227
257
|
): string;
|
|
228
258
|
```
|
|
229
259
|
|
|
260
|
+
| Type | With final consonant | Without final consonant |
|
|
261
|
+
|------|---------------------|------------------------|
|
|
262
|
+
| `"을"` | 을 | 를 |
|
|
263
|
+
| `"은"` | 은 | 는 |
|
|
264
|
+
| `"이"` | 이 | 가 |
|
|
265
|
+
| `"와"` | 과 | 와 |
|
|
266
|
+
| `"랑"` | 이랑 | 랑 |
|
|
267
|
+
| `"로"` | 으로 | 로 |
|
|
268
|
+
| `"라"` | 이라 | 라 |
|
|
269
|
+
|
|
230
270
|
### `str.replaceFullWidth`
|
|
231
271
|
|
|
232
272
|
Convert full-width characters to half-width (A-Z, a-z, 0-9, space, parentheses).
|
|
@@ -240,6 +280,8 @@ export function replaceFullWidth(str: string): string;
|
|
|
240
280
|
```typescript
|
|
241
281
|
export function toPascalCase(str: string): string;
|
|
242
282
|
// "hello-world" -> "HelloWorld"
|
|
283
|
+
// "hello_world" -> "HelloWorld"
|
|
284
|
+
// "hello.world" -> "HelloWorld"
|
|
243
285
|
```
|
|
244
286
|
|
|
245
287
|
### `str.toCamelCase`
|
|
@@ -247,6 +289,8 @@ export function toPascalCase(str: string): string;
|
|
|
247
289
|
```typescript
|
|
248
290
|
export function toCamelCase(str: string): string;
|
|
249
291
|
// "hello-world" -> "helloWorld"
|
|
292
|
+
// "hello_world" -> "helloWorld"
|
|
293
|
+
// "HelloWorld" -> "helloWorld"
|
|
250
294
|
```
|
|
251
295
|
|
|
252
296
|
### `str.toKebabCase`
|
|
@@ -254,6 +298,7 @@ export function toCamelCase(str: string): string;
|
|
|
254
298
|
```typescript
|
|
255
299
|
export function toKebabCase(str: string): string;
|
|
256
300
|
// "HelloWorld" -> "hello-world"
|
|
301
|
+
// "helloWorld" -> "hello-world"
|
|
257
302
|
```
|
|
258
303
|
|
|
259
304
|
### `str.toSnakeCase`
|
|
@@ -261,6 +306,7 @@ export function toKebabCase(str: string): string;
|
|
|
261
306
|
```typescript
|
|
262
307
|
export function toSnakeCase(str: string): string;
|
|
263
308
|
// "HelloWorld" -> "hello_world"
|
|
309
|
+
// "helloWorld" -> "hello_world"
|
|
264
310
|
```
|
|
265
311
|
|
|
266
312
|
### `str.isNullOrEmpty`
|
|
@@ -277,6 +323,7 @@ Insert a string at a specific position.
|
|
|
277
323
|
|
|
278
324
|
```typescript
|
|
279
325
|
export function insert(str: string, index: number, insertString: string): string;
|
|
326
|
+
// insert("Hello World", 5, ",") => "Hello, World"
|
|
280
327
|
```
|
|
281
328
|
|
|
282
329
|
---
|
|
@@ -499,6 +546,8 @@ Transferable conversion utility for Worker data transfer. Handles custom types t
|
|
|
499
546
|
|
|
500
547
|
Source: `src/utils/transferable.ts`
|
|
501
548
|
|
|
549
|
+
Supported types: Date, DateTime, DateOnly, Time, Uuid, RegExp, Error (including cause, code, detail), Uint8Array, Array, Map, Set, plain objects.
|
|
550
|
+
|
|
502
551
|
### `transfer.encode`
|
|
503
552
|
|
|
504
553
|
Convert objects using Simplysm types to plain objects for Worker transfer.
|
|
@@ -536,7 +585,7 @@ Error utility. Source: `src/utils/error.ts`
|
|
|
536
585
|
|
|
537
586
|
### `err.message`
|
|
538
587
|
|
|
539
|
-
Extract message from unknown type error.
|
|
588
|
+
Extract message from unknown type error. Returns `message` property for `Error` instances, otherwise `String(err)`.
|
|
540
589
|
|
|
541
590
|
```typescript
|
|
542
591
|
export function message(err: unknown): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/core-common",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.99",
|
|
4
4
|
"description": "Simplysm package - Core module (common)",
|
|
5
5
|
"author": "simplysm",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"@zip.js/zip.js": "^2.8.23",
|
|
33
33
|
"consola": "^3.4.2",
|
|
34
34
|
"fast-xml-parser": "^5.5.8",
|
|
35
|
-
"yaml": "^2.8.
|
|
35
|
+
"yaml": "^2.8.3"
|
|
36
36
|
}
|
|
37
37
|
}
|