@simplysm/core-common 13.0.100 → 14.0.4

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 (184) hide show
  1. package/README.md +86 -92
  2. package/dist/common.types.d.ts +14 -14
  3. package/dist/common.types.js +2 -1
  4. package/dist/common.types.js.map +1 -6
  5. package/dist/env.d.ts +8 -1
  6. package/dist/env.d.ts.map +1 -1
  7. package/dist/env.js +13 -9
  8. package/dist/env.js.map +1 -6
  9. package/dist/errors/argument-error.d.ts +10 -10
  10. package/dist/errors/argument-error.d.ts.map +1 -1
  11. package/dist/errors/argument-error.js +31 -14
  12. package/dist/errors/argument-error.js.map +1 -6
  13. package/dist/errors/not-implemented-error.d.ts +8 -8
  14. package/dist/errors/not-implemented-error.js +30 -12
  15. package/dist/errors/not-implemented-error.js.map +1 -6
  16. package/dist/errors/sd-error.d.ts +10 -10
  17. package/dist/errors/sd-error.d.ts.map +1 -1
  18. package/dist/errors/sd-error.js +45 -24
  19. package/dist/errors/sd-error.js.map +1 -6
  20. package/dist/errors/timeout-error.d.ts +10 -10
  21. package/dist/errors/timeout-error.js +34 -15
  22. package/dist/errors/timeout-error.js.map +1 -6
  23. package/dist/extensions/arr-ext.d.ts +2 -2
  24. package/dist/extensions/arr-ext.helpers.d.ts +10 -10
  25. package/dist/extensions/arr-ext.helpers.js +112 -89
  26. package/dist/extensions/arr-ext.helpers.js.map +1 -6
  27. package/dist/extensions/arr-ext.js +458 -422
  28. package/dist/extensions/arr-ext.js.map +1 -6
  29. package/dist/extensions/arr-ext.types.d.ts +57 -57
  30. package/dist/extensions/arr-ext.types.d.ts.map +1 -1
  31. package/dist/extensions/arr-ext.types.js +6 -1
  32. package/dist/extensions/arr-ext.types.js.map +1 -6
  33. package/dist/extensions/map-ext.d.ts +16 -16
  34. package/dist/extensions/map-ext.js +27 -22
  35. package/dist/extensions/map-ext.js.map +1 -6
  36. package/dist/extensions/set-ext.d.ts +11 -11
  37. package/dist/extensions/set-ext.js +32 -25
  38. package/dist/extensions/set-ext.js.map +1 -6
  39. package/dist/features/debounce-queue.d.ts +17 -17
  40. package/dist/features/debounce-queue.js +98 -70
  41. package/dist/features/debounce-queue.js.map +1 -6
  42. package/dist/features/event-emitter.d.ts +20 -20
  43. package/dist/features/event-emitter.js +101 -78
  44. package/dist/features/event-emitter.js.map +1 -6
  45. package/dist/features/serial-queue.d.ts +11 -11
  46. package/dist/features/serial-queue.js +78 -57
  47. package/dist/features/serial-queue.js.map +1 -6
  48. package/dist/globals.d.ts +4 -4
  49. package/dist/globals.js +9 -1
  50. package/dist/globals.js.map +1 -6
  51. package/dist/index.js +28 -27
  52. package/dist/index.js.map +1 -6
  53. package/dist/types/date-only.d.ts +64 -64
  54. package/dist/types/date-only.d.ts.map +1 -1
  55. package/dist/types/date-only.js +263 -252
  56. package/dist/types/date-only.js.map +1 -6
  57. package/dist/types/date-time.d.ts +36 -36
  58. package/dist/types/date-time.d.ts.map +1 -1
  59. package/dist/types/date-time.js +196 -288
  60. package/dist/types/date-time.js.map +1 -6
  61. package/dist/types/lazy-gc-map.d.ts +26 -26
  62. package/dist/types/lazy-gc-map.d.ts.map +1 -1
  63. package/dist/types/lazy-gc-map.js +202 -159
  64. package/dist/types/lazy-gc-map.js.map +1 -6
  65. package/dist/types/time.d.ts +23 -23
  66. package/dist/types/time.d.ts.map +1 -1
  67. package/dist/types/time.js +169 -158
  68. package/dist/types/time.js.map +1 -6
  69. package/dist/types/uuid.d.ts +11 -11
  70. package/dist/types/uuid.d.ts.map +1 -1
  71. package/dist/types/uuid.js +95 -70
  72. package/dist/types/uuid.js.map +1 -6
  73. package/dist/utils/bytes.d.ts +17 -17
  74. package/dist/utils/bytes.js +137 -81
  75. package/dist/utils/bytes.js.map +1 -6
  76. package/dist/utils/date-format.d.ts +40 -40
  77. package/dist/utils/date-format.js +187 -101
  78. package/dist/utils/date-format.js.map +1 -6
  79. package/dist/utils/error.d.ts +4 -4
  80. package/dist/utils/error.js +11 -6
  81. package/dist/utils/error.js.map +1 -6
  82. package/dist/utils/json.d.ts +19 -19
  83. package/dist/utils/json.js +187 -135
  84. package/dist/utils/json.js.map +1 -6
  85. package/dist/utils/num.d.ts +20 -20
  86. package/dist/utils/num.js +76 -34
  87. package/dist/utils/num.js.map +1 -6
  88. package/dist/utils/obj.d.ts +111 -111
  89. package/dist/utils/obj.d.ts.map +1 -1
  90. package/dist/utils/obj.js +706 -496
  91. package/dist/utils/obj.js.map +1 -6
  92. package/dist/utils/path.d.ts +10 -10
  93. package/dist/utils/path.js +35 -18
  94. package/dist/utils/path.js.map +1 -6
  95. package/dist/utils/primitive.d.ts +5 -5
  96. package/dist/utils/primitive.js +34 -14
  97. package/dist/utils/primitive.js.map +1 -6
  98. package/dist/utils/str.d.ts +38 -38
  99. package/dist/utils/str.js +217 -113
  100. package/dist/utils/str.js.map +1 -6
  101. package/dist/utils/template-strings.d.ts +26 -26
  102. package/dist/utils/template-strings.js +113 -40
  103. package/dist/utils/template-strings.js.map +1 -6
  104. package/dist/utils/transferable.d.ts +18 -18
  105. package/dist/utils/transferable.js +218 -151
  106. package/dist/utils/transferable.js.map +1 -6
  107. package/dist/utils/wait.d.ts +9 -9
  108. package/dist/utils/wait.js +30 -15
  109. package/dist/utils/wait.js.map +1 -6
  110. package/dist/utils/xml.d.ts +13 -13
  111. package/dist/utils/xml.js +84 -46
  112. package/dist/utils/xml.js.map +1 -6
  113. package/dist/utils/zip.d.ts +22 -22
  114. package/dist/utils/zip.js +172 -148
  115. package/dist/utils/zip.js.map +1 -6
  116. package/docs/array-extensions.md +430 -0
  117. package/docs/env.md +52 -0
  118. package/docs/errors.md +41 -56
  119. package/docs/features.md +82 -97
  120. package/docs/type-utilities.md +91 -0
  121. package/docs/types.md +221 -201
  122. package/docs/utils.md +319 -435
  123. package/package.json +7 -5
  124. package/src/common.types.ts +14 -14
  125. package/src/env.ts +12 -3
  126. package/src/errors/argument-error.ts +15 -15
  127. package/src/errors/not-implemented-error.ts +9 -9
  128. package/src/errors/sd-error.ts +12 -12
  129. package/src/errors/timeout-error.ts +12 -12
  130. package/src/extensions/arr-ext.helpers.ts +16 -16
  131. package/src/extensions/arr-ext.ts +35 -35
  132. package/src/extensions/arr-ext.types.ts +57 -57
  133. package/src/extensions/map-ext.ts +16 -16
  134. package/src/extensions/set-ext.ts +11 -11
  135. package/src/features/debounce-queue.ts +23 -23
  136. package/src/features/event-emitter.ts +25 -25
  137. package/src/features/serial-queue.ts +13 -13
  138. package/src/globals.ts +4 -4
  139. package/src/index.ts +5 -5
  140. package/src/types/date-only.ts +84 -83
  141. package/src/types/date-time.ts +43 -42
  142. package/src/types/lazy-gc-map.ts +44 -44
  143. package/src/types/time.ts +29 -29
  144. package/src/types/uuid.ts +15 -15
  145. package/src/utils/bytes.ts +35 -35
  146. package/src/utils/date-format.ts +59 -59
  147. package/src/utils/error.ts +4 -4
  148. package/src/utils/json.ts +41 -41
  149. package/src/utils/num.ts +20 -20
  150. package/src/utils/obj.ts +138 -138
  151. package/src/utils/path.ts +10 -10
  152. package/src/utils/primitive.ts +6 -6
  153. package/src/utils/str.ts +48 -48
  154. package/src/utils/template-strings.ts +29 -29
  155. package/src/utils/transferable.ts +38 -38
  156. package/src/utils/wait.ts +10 -10
  157. package/src/utils/xml.ts +19 -19
  158. package/src/utils/zip.ts +25 -25
  159. package/docs/extensions.md +0 -387
  160. package/tests/errors/errors.spec.ts +0 -80
  161. package/tests/extensions/array-extension.spec.ts +0 -654
  162. package/tests/extensions/map-extension.spec.ts +0 -117
  163. package/tests/extensions/set-extension.spec.ts +0 -67
  164. package/tests/types/date-only.spec.ts +0 -533
  165. package/tests/types/date-time.spec.ts +0 -246
  166. package/tests/types/lazy-gc-map.spec.ts +0 -606
  167. package/tests/types/time.spec.ts +0 -428
  168. package/tests/types/uuid.spec.ts +0 -74
  169. package/tests/utils/bytes-utils.spec.ts +0 -197
  170. package/tests/utils/date-format.spec.ts +0 -350
  171. package/tests/utils/debounce-queue.spec.ts +0 -226
  172. package/tests/utils/json.spec.ts +0 -400
  173. package/tests/utils/number.spec.ts +0 -136
  174. package/tests/utils/object.spec.ts +0 -810
  175. package/tests/utils/path.spec.ts +0 -70
  176. package/tests/utils/primitive.spec.ts +0 -43
  177. package/tests/utils/sd-event-emitter.spec.ts +0 -189
  178. package/tests/utils/serial-queue.spec.ts +0 -305
  179. package/tests/utils/string.spec.ts +0 -265
  180. package/tests/utils/template-strings.spec.ts +0 -48
  181. package/tests/utils/transferable.spec.ts +0 -639
  182. package/tests/utils/wait.spec.ts +0 -123
  183. package/tests/utils/xml.spec.ts +0 -146
  184. package/tests/utils/zip.spec.ts +0 -221
@@ -1,265 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { str } from "@simplysm/core-common";
3
-
4
- describe("string utils", () => {
5
- //#region koreanGetSuffix - Korean postposition handling
6
-
7
- describe("koreanGetSuffix()", () => {
8
- describe("with final consonant", () => {
9
- it("'을' type returns '을'", () => {
10
- expect(str.getKoreanSuffix("책", "을")).toBe("을");
11
- });
12
-
13
- it("'은' type returns '은'", () => {
14
- expect(str.getKoreanSuffix("책", "은")).toBe("은");
15
- });
16
-
17
- it("'이' type returns '이'", () => {
18
- expect(str.getKoreanSuffix("책", "이")).toBe("이");
19
- });
20
-
21
- it("'와' type returns '과'", () => {
22
- expect(str.getKoreanSuffix("책", "와")).toBe("과");
23
- });
24
-
25
- it("'랑' type returns '이랑'", () => {
26
- expect(str.getKoreanSuffix("책", "랑")).toBe("이랑");
27
- });
28
-
29
- it("'로' type returns '으로'", () => {
30
- expect(str.getKoreanSuffix("책", "로")).toBe("으로");
31
- });
32
-
33
- it("'라' type returns '이라'", () => {
34
- expect(str.getKoreanSuffix("책", "라")).toBe("이라");
35
- });
36
- });
37
-
38
- describe("non-Korean character cases", () => {
39
- it("treats words ending with English letter as no final consonant", () => {
40
- expect(str.getKoreanSuffix("ABC", "을")).toBe("를");
41
- expect(str.getKoreanSuffix("test", "은")).toBe("는");
42
- });
43
-
44
- it("treats words ending with number as no final consonant", () => {
45
- expect(str.getKoreanSuffix("123", "을")).toBe("를");
46
- expect(str.getKoreanSuffix("456", "은")).toBe("는");
47
- });
48
-
49
- it("empty string treated as no final consonant", () => {
50
- expect(str.getKoreanSuffix("", "을")).toBe("를");
51
- expect(str.getKoreanSuffix("", "은")).toBe("는");
52
- });
53
- });
54
-
55
- describe("without final consonant", () => {
56
- it("'을' type returns '를'", () => {
57
- expect(str.getKoreanSuffix("나무", "을")).toBe("를");
58
- });
59
-
60
- it("'은' type returns '는'", () => {
61
- expect(str.getKoreanSuffix("나무", "은")).toBe("는");
62
- });
63
-
64
- it("'이' type returns '가'", () => {
65
- expect(str.getKoreanSuffix("나무", "이")).toBe("가");
66
- });
67
-
68
- it("'와' type returns '와'", () => {
69
- expect(str.getKoreanSuffix("나무", "와")).toBe("와");
70
- });
71
-
72
- it("'랑' type returns '랑'", () => {
73
- expect(str.getKoreanSuffix("나무", "랑")).toBe("랑");
74
- });
75
-
76
- it("'로' type returns '로'", () => {
77
- expect(str.getKoreanSuffix("나무", "로")).toBe("로");
78
- });
79
-
80
- it("'라' type returns '라'", () => {
81
- expect(str.getKoreanSuffix("나무", "라")).toBe("라");
82
- });
83
- });
84
-
85
- describe("final consonant ㄹ (special '로' handling)", () => {
86
- it("'로' type returns '로' for final ㄹ (Seoul)", () => {
87
- expect(str.getKoreanSuffix("서울", "로")).toBe("로");
88
- });
89
-
90
- it("'로' type returns '로' for final ㄹ (road)", () => {
91
- expect(str.getKoreanSuffix("길", "로")).toBe("로");
92
- });
93
-
94
- it("'로' type returns '로' for final ㄹ (foot)", () => {
95
- expect(str.getKoreanSuffix("발", "로")).toBe("로");
96
- });
97
-
98
- it("'로' type returns '로' for final ㄹ (alcohol)", () => {
99
- expect(str.getKoreanSuffix("술", "로")).toBe("로");
100
- });
101
-
102
- it("'을' type returns '을' for final ㄹ by general rule", () => {
103
- expect(str.getKoreanSuffix("서울", "을")).toBe("을");
104
- });
105
-
106
- it("'은' type returns '은' for final ㄹ by general rule", () => {
107
- expect(str.getKoreanSuffix("서울", "은")).toBe("은");
108
- });
109
- });
110
- });
111
-
112
- //#endregion
113
-
114
- //#endregion
115
-
116
- //#region strReplaceFullWidth - Full-width to half-width conversion
117
-
118
- describe("replaceFullWidth()", () => {
119
- it("converts full-width alphabet to half-width", () => {
120
- expect(str.replaceFullWidth("ABCDEFG")).toBe("ABCDEFG");
121
- expect(str.replaceFullWidth("HIJKLMN")).toBe("HIJKLMN");
122
- expect(str.replaceFullWidth("OPQRSTU")).toBe("OPQRSTU");
123
- expect(str.replaceFullWidth("VWXYZ")).toBe("VWXYZ");
124
- });
125
-
126
- it("converts full-width number to half-width", () => {
127
- expect(str.replaceFullWidth("0123456789")).toBe("0123456789");
128
- });
129
-
130
- it("converts full-width parenthesis to half-width", () => {
131
- expect(str.replaceFullWidth("(ABC)")).toBe("(ABC)");
132
- });
133
-
134
- it("converts full-width space to half-width space", () => {
135
- expect(str.replaceFullWidth("A B C")).toBe("A B C");
136
- });
137
-
138
- it("converts mixed full-width/half-width string", () => {
139
- expect(str.replaceFullWidth("ABC123")).toBe("ABC123");
140
- });
141
-
142
- it("returns original if no full-width characters", () => {
143
- expect(str.replaceFullWidth("ABC123")).toBe("ABC123");
144
- });
145
- });
146
-
147
- //#endregion
148
-
149
- //#endregion
150
-
151
- //#region Case conversion
152
-
153
- describe("toPascalCase()", () => {
154
- it("converts kebab-case to PascalCase", () => {
155
- expect(str.toPascalCase("hello-world")).toBe("HelloWorld");
156
- });
157
-
158
- it("converts dot.case to PascalCase", () => {
159
- expect(str.toPascalCase("hello.world")).toBe("HelloWorld");
160
- });
161
-
162
- it("converts snake_case to PascalCase", () => {
163
- expect(str.toPascalCase("hello_world")).toBe("HelloWorld");
164
- });
165
-
166
- it("capitalizes first letter of lowercase string", () => {
167
- expect(str.toPascalCase("hello")).toBe("Hello");
168
- });
169
-
170
- it("returns as-is if already PascalCase", () => {
171
- expect(str.toPascalCase("HelloWorld")).toBe("HelloWorld");
172
- });
173
-
174
- it("handles consecutive hyphens", () => {
175
- expect(str.toPascalCase("hello-world-test")).toBe("HelloWorldTest");
176
- });
177
- });
178
-
179
- describe("toCamelCase()", () => {
180
- it("converts kebab-case to camelCase", () => {
181
- expect(str.toCamelCase("hello-world")).toBe("helloWorld");
182
- });
183
-
184
- it("converts PascalCase to camelCase", () => {
185
- expect(str.toCamelCase("HelloWorld")).toBe("helloWorld");
186
- });
187
-
188
- it("converts dot.case to camelCase", () => {
189
- expect(str.toCamelCase("hello.world")).toBe("helloWorld");
190
- });
191
-
192
- it("converts snake_case to camelCase", () => {
193
- expect(str.toCamelCase("hello_world")).toBe("helloWorld");
194
- });
195
-
196
- it("returns as-is if already camelCase", () => {
197
- expect(str.toCamelCase("helloWorld")).toBe("helloWorld");
198
- });
199
- });
200
-
201
- describe("toKebabCase()", () => {
202
- it("converts PascalCase to kebab-case", () => {
203
- expect(str.toKebabCase("HelloWorld")).toBe("hello-world");
204
- });
205
-
206
- it("converts camelCase to kebab-case", () => {
207
- expect(str.toKebabCase("helloWorld")).toBe("hello-world");
208
- });
209
-
210
- it("adds hyphen before underscore when present", () => {
211
- // toKebabCase converts [-_]?[A-Z] to -lowercase, so _W → -_w
212
- expect(str.toKebabCase("Hello_World")).toBe("hello-_world");
213
- });
214
-
215
- it("returns as-is if already kebab-case", () => {
216
- expect(str.toKebabCase("hello-world")).toBe("hello-world");
217
- });
218
-
219
- it("handles consecutive uppercase letters", () => {
220
- expect(str.toKebabCase("HelloWorldTest")).toBe("hello-world-test");
221
- });
222
-
223
- it("handles consecutive uppercase followed by lowercase", () => {
224
- // each uppercase letter treated as separate word
225
- expect(str.toKebabCase("XMLParser")).toBe("x-m-l-parser");
226
- expect(str.toKebabCase("HTTPSConnection")).toBe("h-t-t-p-s-connection");
227
- });
228
- });
229
-
230
- describe("toSnakeCase()", () => {
231
- it("converts PascalCase to snake_case", () => {
232
- expect(str.toSnakeCase("HelloWorld")).toBe("hello_world");
233
- });
234
-
235
- it("converts camelCase to snake_case", () => {
236
- expect(str.toSnakeCase("helloWorld")).toBe("hello_world");
237
- });
238
-
239
- it("returns as-is if already snake_case", () => {
240
- expect(str.toSnakeCase("hello_world")).toBe("hello_world");
241
- });
242
-
243
- it("handles consecutive uppercase letters", () => {
244
- expect(str.toSnakeCase("HelloWorldTest")).toBe("hello_world_test");
245
- });
246
- });
247
-
248
- //#endregion
249
-
250
- //#endregion
251
-
252
- //#region Other
253
-
254
- describe("insert()", () => {
255
- it("inserts at start of string", () => {
256
- expect(str.insert("world", 0, "hello ")).toBe("hello world");
257
- });
258
-
259
- it("inserts at end of string", () => {
260
- expect(str.insert("hello", 5, " world")).toBe("hello world");
261
- });
262
- });
263
-
264
- //#endregion
265
- });
@@ -1,48 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { html, js } from "../../src/index.js";
3
-
4
- describe("template-strings", () => {
5
- describe("Basic behavior", () => {
6
- it("String concatenation", () => {
7
- const name = "test";
8
- expect(js`const x = "${name}"`).toBe('const x = "test"');
9
- });
10
-
11
- it("Removes indentation", () => {
12
- const result = js`
13
- const x = 1;
14
- const y = 2;
15
- `;
16
- expect(result).toBe("const x = 1;\nconst y = 2;");
17
- });
18
-
19
- it("Removes first/last empty lines", () => {
20
- const result = html`
21
- <div>test</div>
22
- `;
23
- expect(result).toBe("<div>test</div>");
24
- });
25
-
26
- it("Preserves middle empty lines", () => {
27
- const result = js`
28
- const x = 1;
29
-
30
- const y = 2;
31
- `;
32
- expect(result).toBe("const x = 1;\n\nconst y = 2;");
33
- });
34
- });
35
-
36
- describe("Value interpolation", () => {
37
- it("Handles undefined value", () => {
38
- const value = undefined;
39
- expect(js`x = ${value}`).toBe("x = ");
40
- });
41
-
42
- it("Interpolates multiple values", () => {
43
- const a = 1;
44
- const b = 2;
45
- expect(js`${a} + ${b} = ${a + b}`).toBe("1 + 2 = 3");
46
- });
47
- });
48
- });