@simplysm/core-common 13.0.0-beta.6 → 13.0.0-beta.7

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 (65) hide show
  1. package/package.json +6 -3
  2. package/.cache/typecheck-browser.tsbuildinfo +0 -1
  3. package/.cache/typecheck-node.tsbuildinfo +0 -1
  4. package/.cache/typecheck-tests-browser.tsbuildinfo +0 -1
  5. package/.cache/typecheck-tests-node.tsbuildinfo +0 -1
  6. package/src/common.types.ts +0 -91
  7. package/src/env.ts +0 -11
  8. package/src/errors/argument-error.ts +0 -40
  9. package/src/errors/not-implemented-error.ts +0 -32
  10. package/src/errors/sd-error.ts +0 -53
  11. package/src/errors/timeout-error.ts +0 -36
  12. package/src/extensions/arr-ext.helpers.ts +0 -53
  13. package/src/extensions/arr-ext.ts +0 -777
  14. package/src/extensions/arr-ext.types.ts +0 -258
  15. package/src/extensions/map-ext.ts +0 -86
  16. package/src/extensions/set-ext.ts +0 -68
  17. package/src/features/debounce-queue.ts +0 -116
  18. package/src/features/event-emitter.ts +0 -112
  19. package/src/features/serial-queue.ts +0 -94
  20. package/src/globals.ts +0 -12
  21. package/src/index.ts +0 -55
  22. package/src/types/date-only.ts +0 -329
  23. package/src/types/date-time.ts +0 -294
  24. package/src/types/lazy-gc-map.ts +0 -244
  25. package/src/types/time.ts +0 -210
  26. package/src/types/uuid.ts +0 -113
  27. package/src/utils/bytes.ts +0 -160
  28. package/src/utils/date-format.ts +0 -239
  29. package/src/utils/json.ts +0 -230
  30. package/src/utils/num.ts +0 -97
  31. package/src/utils/obj.ts +0 -956
  32. package/src/utils/path.ts +0 -40
  33. package/src/utils/primitive.ts +0 -33
  34. package/src/utils/str.ts +0 -252
  35. package/src/utils/template-strings.ts +0 -132
  36. package/src/utils/transferable.ts +0 -269
  37. package/src/utils/wait.ts +0 -40
  38. package/src/utils/xml.ts +0 -105
  39. package/src/zip/sd-zip.ts +0 -218
  40. package/tests/errors/errors.spec.ts +0 -196
  41. package/tests/extensions/array-extension.spec.ts +0 -790
  42. package/tests/extensions/map-extension.spec.ts +0 -147
  43. package/tests/extensions/set-extension.spec.ts +0 -74
  44. package/tests/types/date-only.spec.ts +0 -636
  45. package/tests/types/date-time.spec.ts +0 -391
  46. package/tests/types/lazy-gc-map.spec.ts +0 -692
  47. package/tests/types/time.spec.ts +0 -559
  48. package/tests/types/types.spec.ts +0 -55
  49. package/tests/types/uuid.spec.ts +0 -91
  50. package/tests/utils/bytes-utils.spec.ts +0 -230
  51. package/tests/utils/date-format.spec.ts +0 -371
  52. package/tests/utils/debounce-queue.spec.ts +0 -272
  53. package/tests/utils/json.spec.ts +0 -475
  54. package/tests/utils/number.spec.ts +0 -184
  55. package/tests/utils/object.spec.ts +0 -827
  56. package/tests/utils/path.spec.ts +0 -78
  57. package/tests/utils/primitive.spec.ts +0 -55
  58. package/tests/utils/sd-event-emitter.spec.ts +0 -216
  59. package/tests/utils/serial-queue.spec.ts +0 -365
  60. package/tests/utils/string.spec.ts +0 -294
  61. package/tests/utils/template-strings.spec.ts +0 -96
  62. package/tests/utils/transferable.spec.ts +0 -698
  63. package/tests/utils/wait.spec.ts +0 -145
  64. package/tests/utils/xml.spec.ts +0 -146
  65. package/tests/zip/sd-zip.spec.ts +0 -234
@@ -1,294 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import {
3
- strGetSuffix,
4
- strReplaceFullWidth,
5
- strToPascalCase,
6
- strToCamelCase,
7
- strToKebabCase,
8
- strToSnakeCase,
9
- strIsNullOrEmpty,
10
- strInsert,
11
- } from "@simplysm/core-common";
12
-
13
- describe("string utils", () => {
14
- //#region getSuffix - 한글 조사 처리
15
-
16
- describe("strGetSuffix()", () => {
17
- describe("받침이 있는 경우", () => {
18
- it("'을' 타입은 '을'을 반환한다", () => {
19
- expect(strGetSuffix("책", "을")).toBe("을");
20
- });
21
-
22
- it("'은' 타입은 '은'을 반환한다", () => {
23
- expect(strGetSuffix("책", "은")).toBe("은");
24
- });
25
-
26
- it("'이' 타입은 '이'를 반환한다", () => {
27
- expect(strGetSuffix("책", "이")).toBe("이");
28
- });
29
-
30
- it("'와' 타입은 '과'를 반환한다", () => {
31
- expect(strGetSuffix("책", "와")).toBe("과");
32
- });
33
-
34
- it("'랑' 타입은 '이랑'을 반환한다", () => {
35
- expect(strGetSuffix("책", "랑")).toBe("이랑");
36
- });
37
-
38
- it("'로' 타입은 '으로'를 반환한다", () => {
39
- expect(strGetSuffix("책", "로")).toBe("으로");
40
- });
41
-
42
- it("'라' 타입은 '이라'를 반환한다", () => {
43
- expect(strGetSuffix("책", "라")).toBe("이라");
44
- });
45
- });
46
-
47
- describe("비한글 문자의 경우", () => {
48
- it("영문자로 끝나면 받침 없음으로 처리한다", () => {
49
- expect(strGetSuffix("ABC", "을")).toBe("를");
50
- expect(strGetSuffix("test", "은")).toBe("는");
51
- });
52
-
53
- it("숫자로 끝나면 받침 없음으로 처리한다", () => {
54
- expect(strGetSuffix("123", "을")).toBe("를");
55
- expect(strGetSuffix("456", "은")).toBe("는");
56
- });
57
-
58
- it("빈 문자열은 받침 없음으로 처리한다", () => {
59
- expect(strGetSuffix("", "을")).toBe("를");
60
- expect(strGetSuffix("", "은")).toBe("는");
61
- });
62
- });
63
-
64
- describe("받침이 없는 경우", () => {
65
- it("'을' 타입은 '를'을 반환한다", () => {
66
- expect(strGetSuffix("나무", "을")).toBe("를");
67
- });
68
-
69
- it("'은' 타입은 '는'을 반환한다", () => {
70
- expect(strGetSuffix("나무", "은")).toBe("는");
71
- });
72
-
73
- it("'이' 타입은 '가'를 반환한다", () => {
74
- expect(strGetSuffix("나무", "이")).toBe("가");
75
- });
76
-
77
- it("'와' 타입은 '와'를 반환한다", () => {
78
- expect(strGetSuffix("나무", "와")).toBe("와");
79
- });
80
-
81
- it("'랑' 타입은 '랑'을 반환한다", () => {
82
- expect(strGetSuffix("나무", "랑")).toBe("랑");
83
- });
84
-
85
- it("'로' 타입은 '로'를 반환한다", () => {
86
- expect(strGetSuffix("나무", "로")).toBe("로");
87
- });
88
-
89
- it("'라' 타입은 '라'를 반환한다", () => {
90
- expect(strGetSuffix("나무", "라")).toBe("라");
91
- });
92
- });
93
-
94
- describe("받침 ㄹ인 경우 (로 조사 특수 처리)", () => {
95
- it("'로' 타입은 받침 ㄹ일 때 '로'를 반환한다 (서울)", () => {
96
- expect(strGetSuffix("서울", "로")).toBe("로");
97
- });
98
-
99
- it("'로' 타입은 받침 ㄹ일 때 '로'를 반환한다 (길)", () => {
100
- expect(strGetSuffix("길", "로")).toBe("로");
101
- });
102
-
103
- it("'로' 타입은 받침 ㄹ일 때 '로'를 반환한다 (발)", () => {
104
- expect(strGetSuffix("발", "로")).toBe("로");
105
- });
106
-
107
- it("'로' 타입은 받침 ㄹ일 때 '로'를 반환한다 (술)", () => {
108
- expect(strGetSuffix("술", "로")).toBe("로");
109
- });
110
-
111
- it("'을' 타입은 받침 ㄹ일 때 일반 규칙대로 '을'을 반환한다", () => {
112
- expect(strGetSuffix("서울", "을")).toBe("을");
113
- });
114
-
115
- it("'은' 타입은 받침 ㄹ일 때 일반 규칙대로 '은'을 반환한다", () => {
116
- expect(strGetSuffix("서울", "은")).toBe("은");
117
- });
118
- });
119
- });
120
-
121
- //#endregion
122
-
123
- //#region replaceSpecialDefaultChar - 전각→반각 변환
124
-
125
- describe("strReplaceFullWidth()", () => {
126
- it("전각 알파벳을 반각으로 변환한다", () => {
127
- expect(strReplaceFullWidth("ABCDEFG")).toBe("ABCDEFG");
128
- expect(strReplaceFullWidth("HIJKLMN")).toBe("HIJKLMN");
129
- expect(strReplaceFullWidth("OPQRSTU")).toBe("OPQRSTU");
130
- expect(strReplaceFullWidth("VWXYZ")).toBe("VWXYZ");
131
- });
132
-
133
- it("전각 숫자를 반각으로 변환한다", () => {
134
- expect(strReplaceFullWidth("0123456789")).toBe("0123456789");
135
- });
136
-
137
- it("전각 괄호를 반각으로 변환한다", () => {
138
- expect(strReplaceFullWidth("(ABC)")).toBe("(ABC)");
139
- });
140
-
141
- it("전각 공백을 반각 공백으로 변환한다", () => {
142
- expect(strReplaceFullWidth("A B C")).toBe("A B C");
143
- });
144
-
145
- it("혼합된 전각/반각 문자열을 변환한다", () => {
146
- expect(strReplaceFullWidth("ABC123")).toBe("ABC123");
147
- });
148
-
149
- it("전각 문자가 없는 경우 원본을 반환한다", () => {
150
- expect(strReplaceFullWidth("ABC123")).toBe("ABC123");
151
- });
152
- });
153
-
154
- //#endregion
155
-
156
- //#region 케이스 변환
157
-
158
- describe("strToPascalCase()", () => {
159
- it("kebab-case를 PascalCase로 변환한다", () => {
160
- expect(strToPascalCase("hello-world")).toBe("HelloWorld");
161
- });
162
-
163
- it("dot.case를 PascalCase로 변환한다", () => {
164
- expect(strToPascalCase("hello.world")).toBe("HelloWorld");
165
- });
166
-
167
- it("snake_case를 PascalCase로 변환한다", () => {
168
- expect(strToPascalCase("hello_world")).toBe("HelloWorld");
169
- });
170
-
171
- it("소문자로 시작하는 문자열의 첫 글자를 대문자로 변환한다", () => {
172
- expect(strToPascalCase("hello")).toBe("Hello");
173
- });
174
-
175
- it("이미 PascalCase인 경우 그대로 반환한다", () => {
176
- expect(strToPascalCase("HelloWorld")).toBe("HelloWorld");
177
- });
178
-
179
- it("연속된 하이픈을 처리한다", () => {
180
- expect(strToPascalCase("hello-world-test")).toBe("HelloWorldTest");
181
- });
182
- });
183
-
184
- describe("strToCamelCase()", () => {
185
- it("kebab-case를 camelCase로 변환한다", () => {
186
- expect(strToCamelCase("hello-world")).toBe("helloWorld");
187
- });
188
-
189
- it("PascalCase를 camelCase로 변환한다", () => {
190
- expect(strToCamelCase("HelloWorld")).toBe("helloWorld");
191
- });
192
-
193
- it("dot.case를 camelCase로 변환한다", () => {
194
- expect(strToCamelCase("hello.world")).toBe("helloWorld");
195
- });
196
-
197
- it("snake_case를 camelCase로 변환한다", () => {
198
- expect(strToCamelCase("hello_world")).toBe("helloWorld");
199
- });
200
-
201
- it("이미 camelCase인 경우 그대로 반환한다", () => {
202
- expect(strToCamelCase("helloWorld")).toBe("helloWorld");
203
- });
204
- });
205
-
206
- describe("strToKebabCase()", () => {
207
- it("PascalCase를 kebab-case로 변환한다", () => {
208
- expect(strToKebabCase("HelloWorld")).toBe("hello-world");
209
- });
210
-
211
- it("camelCase를 kebab-case로 변환한다", () => {
212
- expect(strToKebabCase("helloWorld")).toBe("hello-world");
213
- });
214
-
215
- it("언더스코어가 포함된 경우 언더스코어 앞에 하이픈을 추가한다", () => {
216
- // toKebabCase는 [-_]?[A-Z]를 -소문자로 변환하므로 _W → -_w가 됨
217
- expect(strToKebabCase("Hello_World")).toBe("hello-_world");
218
- });
219
-
220
- it("이미 kebab-case인 경우 그대로 반환한다", () => {
221
- expect(strToKebabCase("hello-world")).toBe("hello-world");
222
- });
223
-
224
- it("연속된 대문자를 처리한다", () => {
225
- expect(strToKebabCase("HelloWorldTest")).toBe("hello-world-test");
226
- });
227
-
228
- it("연속된 대문자 후 소문자가 오는 경우를 처리한다", () => {
229
- // 각 대문자를 개별 단어로 취급
230
- expect(strToKebabCase("XMLParser")).toBe("x-m-l-parser");
231
- expect(strToKebabCase("HTTPSConnection")).toBe("h-t-t-p-s-connection");
232
- });
233
- });
234
-
235
- describe("strToSnakeCase()", () => {
236
- it("PascalCase를 snake_case로 변환한다", () => {
237
- expect(strToSnakeCase("HelloWorld")).toBe("hello_world");
238
- });
239
-
240
- it("camelCase를 snake_case로 변환한다", () => {
241
- expect(strToSnakeCase("helloWorld")).toBe("hello_world");
242
- });
243
-
244
- it("이미 snake_case인 경우 그대로 반환한다", () => {
245
- expect(strToSnakeCase("hello_world")).toBe("hello_world");
246
- });
247
-
248
- it("연속된 대문자를 처리한다", () => {
249
- expect(strToSnakeCase("HelloWorldTest")).toBe("hello_world_test");
250
- });
251
- });
252
-
253
- //#endregion
254
-
255
- //#region 기타
256
-
257
- describe("strIsNullOrEmpty()", () => {
258
- it("undefined이면 true를 반환한다", () => {
259
- expect(strIsNullOrEmpty(undefined)).toBe(true);
260
- });
261
-
262
- it("빈 문자열이면 true를 반환한다", () => {
263
- expect(strIsNullOrEmpty("")).toBe(true);
264
- });
265
-
266
- it("일반 문자열이면 false를 반환한다", () => {
267
- expect(strIsNullOrEmpty("hello")).toBe(false);
268
- });
269
-
270
- it("공백만 있는 문자열은 false를 반환한다", () => {
271
- expect(strIsNullOrEmpty(" ")).toBe(false);
272
- });
273
- });
274
-
275
- describe("strInsert()", () => {
276
- it("문자열 시작에 삽입한다", () => {
277
- expect(strInsert("world", 0, "hello ")).toBe("hello world");
278
- });
279
-
280
- it("문자열 중간에 삽입한다", () => {
281
- expect(strInsert("helloworld", 5, " ")).toBe("hello world");
282
- });
283
-
284
- it("문자열 끝에 삽입한다", () => {
285
- expect(strInsert("hello", 5, " world")).toBe("hello world");
286
- });
287
-
288
- it("빈 문자열에 삽입한다", () => {
289
- expect(strInsert("", 0, "hello")).toBe("hello");
290
- });
291
- });
292
-
293
- //#endregion
294
- });
@@ -1,96 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { html, js, mysql, pgsql, ts, tsql } from "../../src/index.js";
3
-
4
- describe("template-strings", () => {
5
- describe("기본 동작", () => {
6
- it("문자열 조합", () => {
7
- const name = "test";
8
- expect(js`const x = "${name}"`).toBe('const x = "test"');
9
- });
10
-
11
- it("들여쓰기 제거", () => {
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("첫/마지막 빈 줄 제거", () => {
20
- const result = html`
21
- <div>test</div>
22
- `;
23
- expect(result).toBe("<div>test</div>");
24
- });
25
-
26
- it("중간 빈 줄 유지", () => {
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("SQL 함수들", () => {
37
- it("tsql", () => {
38
- expect(tsql`SELECT * FROM [User]`).toBe("SELECT * FROM [User]");
39
- });
40
-
41
- it("mysql", () => {
42
- expect(mysql`SELECT * FROM \`User\``).toBe("SELECT * FROM `User`");
43
- });
44
-
45
- it("pgsql", () => {
46
- expect(pgsql`SELECT * FROM "User"`).toBe('SELECT * FROM "User"');
47
- });
48
-
49
- it("tsql 멀티라인", () => {
50
- const result = tsql`
51
- SELECT id, name
52
- FROM [User]
53
- WHERE id = 1
54
- `;
55
- expect(result).toBe("SELECT id, name\nFROM [User]\nWHERE id = 1");
56
- });
57
- });
58
-
59
- describe("코드 함수들", () => {
60
- it("js", () => {
61
- expect(js`console.log("hello")`).toBe('console.log("hello")');
62
- });
63
-
64
- it("ts", () => {
65
- expect(ts`const x: number = 1`).toBe("const x: number = 1");
66
- });
67
-
68
- it("html", () => {
69
- expect(html`
70
- <div class="test">content</div>
71
- `).toBe('<div class="test">content</div>');
72
- });
73
- });
74
-
75
- describe("값 보간", () => {
76
- it("undefined 값 처리", () => {
77
- const value = undefined;
78
- expect(js`x = ${value}`).toBe("x = ");
79
- });
80
-
81
- it("숫자 값 처리", () => {
82
- expect(js`x = ${42}`).toBe("x = 42");
83
- });
84
-
85
- it("여러 값 보간", () => {
86
- const a = 1;
87
- const b = 2;
88
- expect(js`${a} + ${b} = ${a + b}`).toBe("1 + 2 = 3");
89
- });
90
-
91
- it("객체 값 처리", () => {
92
- const obj = { toString: () => "custom" };
93
- expect(js`value = ${obj}`).toBe("value = custom");
94
- });
95
- });
96
- });