@ooneex/utils 0.0.6 → 0.1.0
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/LICENSE +21 -0
- package/README.md +539 -203
- package/dist/index.d.ts +24 -16
- package/dist/index.js +3 -1
- package/dist/index.js.map +25 -0
- package/package.json +22 -14
- package/dist/capitalizeWord.d.ts +0 -2
- package/dist/capitalizeWord.d.ts.map +0 -1
- package/dist/dataURLtoFile.d.ts +0 -2
- package/dist/dataURLtoFile.d.ts.map +0 -1
- package/dist/formatRelativeNumber.d.ts +0 -5
- package/dist/formatRelativeNumber.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/millisecondsToHMS.d.ts +0 -2
- package/dist/millisecondsToHMS.d.ts.map +0 -1
- package/dist/parseEnvVars.d.ts +0 -2
- package/dist/parseEnvVars.d.ts.map +0 -1
- package/dist/parseString.d.ts +0 -2
- package/dist/parseString.d.ts.map +0 -1
- package/dist/random.d.ts +0 -6
- package/dist/random.d.ts.map +0 -1
- package/dist/secondsToHMS.d.ts +0 -2
- package/dist/secondsToHMS.d.ts.map +0 -1
- package/dist/secondsToMS.d.ts +0 -2
- package/dist/secondsToMS.d.ts.map +0 -1
- package/dist/sleep.d.ts +0 -2
- package/dist/sleep.d.ts.map +0 -1
- package/dist/splitToWords.d.ts +0 -2
- package/dist/splitToWords.d.ts.map +0 -1
- package/dist/toCamelCase.d.ts +0 -2
- package/dist/toCamelCase.d.ts.map +0 -1
- package/dist/toKebabCase.d.ts +0 -2
- package/dist/toKebabCase.d.ts.map +0 -1
- package/dist/toPascalCase.d.ts +0 -2
- package/dist/toPascalCase.d.ts.map +0 -1
- package/dist/trim.d.ts +0 -2
- package/dist/trim.d.ts.map +0 -1
- package/src/capitalizeWord.ts +0 -3
- package/src/dataURLtoFile.ts +0 -12
- package/src/formatRelativeNumber.ts +0 -7
- package/src/index.ts +0 -15
- package/src/millisecondsToHMS.ts +0 -16
- package/src/parseEnvVars.ts +0 -14
- package/src/parseString.ts +0 -47
- package/src/random.ts +0 -13
- package/src/secondsToHMS.ts +0 -16
- package/src/secondsToMS.ts +0 -5
- package/src/sleep.ts +0 -3
- package/src/splitToWords.ts +0 -14
- package/src/toCamelCase.ts +0 -8
- package/src/toKebabCase.ts +0 -6
- package/src/toPascalCase.ts +0 -7
- package/src/trim.ts +0 -8
- package/tests/capitalizeWord.spec.ts +0 -163
- package/tests/dataURLtoFile.spec.ts +0 -472
- package/tests/formatRelativeNumber.spec.ts +0 -303
- package/tests/millisecondsToHMS.spec.ts +0 -209
- package/tests/parseEnvVars.spec.ts +0 -468
- package/tests/parseString.spec.ts +0 -377
- package/tests/random.spec.ts +0 -422
- package/tests/secondsToHMS.spec.ts +0 -341
- package/tests/secondsToMS.spec.ts +0 -467
- package/tests/splitToWords.spec.ts +0 -359
- package/tests/toCamelCase.spec.ts +0 -526
- package/tests/toKebabCase.spec.ts +0 -664
- package/tests/toPascalCase.spec.ts +0 -721
- package/tests/trim.spec.ts +0 -486
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -11
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { parseString } from "@/index";
|
|
3
|
-
|
|
4
|
-
describe("parseString", () => {
|
|
5
|
-
describe("empty string handling", () => {
|
|
6
|
-
test("should return empty string for empty input", () => {
|
|
7
|
-
expect(parseString("") as string).toBe("");
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
describe("integer parsing", () => {
|
|
12
|
-
test("should parse positive integers", () => {
|
|
13
|
-
expect(parseString("123") as number).toBe(123);
|
|
14
|
-
expect(parseString("0") as number).toBe(0);
|
|
15
|
-
expect(parseString("42") as number).toBe(42);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("should parse negative integers", () => {
|
|
19
|
-
expect(parseString("-123") as number).toBe(-123);
|
|
20
|
-
expect(parseString("-1") as number).toBe(-1);
|
|
21
|
-
expect(parseString("-999") as number).toBe(-999);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("should parse large integers", () => {
|
|
25
|
-
expect(parseString("2147483647") as number).toBe(2147483647);
|
|
26
|
-
expect(parseString("-2147483648") as number).toBe(-2147483648);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("float parsing", () => {
|
|
31
|
-
test("should parse positive floats", () => {
|
|
32
|
-
expect(parseString("123.45") as number).toBe(123.45);
|
|
33
|
-
expect(parseString("0.5") as number).toBe(0.5);
|
|
34
|
-
// biome-ignore lint/suspicious/noApproximativeNumericConstant: trust me
|
|
35
|
-
expect(parseString("3.14159") as number).toBe(3.14159);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("should parse negative floats", () => {
|
|
39
|
-
expect(parseString("-123.45") as number).toBe(-123.45);
|
|
40
|
-
expect(parseString("-0.5") as number).toBe(-0.5);
|
|
41
|
-
expect(parseString("-99.999") as number).toBe(-99.999);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("should parse floats with leading zero", () => {
|
|
45
|
-
expect(parseString("0.123") as number).toBe(0.123);
|
|
46
|
-
expect(parseString("-0.456") as number).toBe(-0.456);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe("scientific notation parsing", () => {
|
|
51
|
-
test("should parse basic scientific notation", () => {
|
|
52
|
-
expect(parseString("1e5") as number).toBe(100000);
|
|
53
|
-
expect(parseString("2e3") as number).toBe(2000);
|
|
54
|
-
expect(parseString("5e0") as number).toBe(5);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("should parse negative base scientific notation", () => {
|
|
58
|
-
expect(parseString("-1e5") as number).toBe(-100000);
|
|
59
|
-
expect(parseString("-2.5e3") as number).toBe(-2500);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("should parse scientific notation with positive exponent", () => {
|
|
63
|
-
expect(parseString("1e+5") as number).toBe(100000);
|
|
64
|
-
expect(parseString("2.5e+3") as number).toBe(2500);
|
|
65
|
-
expect(parseString("1.23e+2") as number).toBe(123);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("should parse scientific notation with negative exponent", () => {
|
|
69
|
-
expect(parseString("1e-3") as number).toBe(0.001);
|
|
70
|
-
expect(parseString("2.5e-2") as number).toBe(0.025);
|
|
71
|
-
expect(parseString("5e-1") as number).toBe(0.5);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("should parse uppercase E notation", () => {
|
|
75
|
-
expect(parseString("1E5") as number).toBe(100000);
|
|
76
|
-
expect(parseString("2.5E-3") as number).toBe(0.0025);
|
|
77
|
-
expect(parseString("-1.2E+10") as number).toBe(-12000000000);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test("should parse decimal scientific notation", () => {
|
|
81
|
-
expect(parseString("1.5e3") as number).toBe(1500);
|
|
82
|
-
expect(parseString("2.25e-1") as number).toBe(0.225);
|
|
83
|
-
expect(parseString("0.5e2") as number).toBe(50);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe("boolean parsing", () => {
|
|
88
|
-
test("should parse true values", () => {
|
|
89
|
-
expect(parseString("true") as boolean).toBe(true);
|
|
90
|
-
expect(parseString("True") as boolean).toBe(true);
|
|
91
|
-
expect(parseString("TRUE") as boolean).toBe(true);
|
|
92
|
-
expect(parseString("TrUe") as boolean).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("should parse false values", () => {
|
|
96
|
-
expect(parseString("false") as boolean).toBe(false);
|
|
97
|
-
expect(parseString("False") as boolean).toBe(false);
|
|
98
|
-
expect(parseString("FALSE") as boolean).toBe(false);
|
|
99
|
-
expect(parseString("FaLsE") as boolean).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe("null and undefined parsing", () => {
|
|
104
|
-
test("should parse null values", () => {
|
|
105
|
-
expect(parseString("null") as null).toBe(null);
|
|
106
|
-
expect(parseString("Null") as null).toBe(null);
|
|
107
|
-
expect(parseString("NULL") as null).toBe(null);
|
|
108
|
-
expect(parseString("NuLl") as null).toBe(null);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe("array parsing", () => {
|
|
113
|
-
test("should parse simple arrays", () => {
|
|
114
|
-
expect(parseString("[1,2,3]") as number[]).toEqual([1, 2, 3]);
|
|
115
|
-
expect(parseString("[1, 2, 3]") as number[]).toEqual([1, 2, 3]);
|
|
116
|
-
expect(parseString("[ 1 , 2 , 3 ]") as number[]).toEqual([1, 2, 3]);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test("should parse arrays with strings", () => {
|
|
120
|
-
expect(parseString('["hello", "world"]') as string[]).toEqual(["hello", "world"]);
|
|
121
|
-
expect(parseString("['a', 'b', 'c']") as string[]).toEqual(["'a'", "'b'", "'c'"]);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test("should parse arrays with objects", () => {
|
|
125
|
-
expect(parseString('[{"a": 1}, {"b": 2}]') as object[]).toEqual([{ a: 1 }, { b: 2 }]);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("object parsing", () => {
|
|
130
|
-
test("should parse empty objects", () => {
|
|
131
|
-
expect(parseString("{}") as object).toEqual({});
|
|
132
|
-
expect(parseString("{ }") as object).toEqual({});
|
|
133
|
-
expect(parseString("{ }") as object).toEqual({});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test("should parse simple objects", () => {
|
|
137
|
-
expect(parseString('{"name": "John"}') as object).toEqual({
|
|
138
|
-
name: "John",
|
|
139
|
-
});
|
|
140
|
-
expect(parseString('{"age": 30}') as object).toEqual({ age: 30 });
|
|
141
|
-
expect(parseString('{"active": true}') as object).toEqual({
|
|
142
|
-
active: true,
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test("should parse objects with multiple properties", () => {
|
|
147
|
-
expect(parseString('{"name": "John", "age": 30}') as object).toEqual({
|
|
148
|
-
name: "John",
|
|
149
|
-
age: 30,
|
|
150
|
-
});
|
|
151
|
-
expect(parseString('{"a": 1, "b": true, "c": null}') as object).toEqual({
|
|
152
|
-
a: 1,
|
|
153
|
-
b: true,
|
|
154
|
-
c: null,
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("should return string for objects with undefined (invalid JSON)", () => {
|
|
159
|
-
expect(parseString('{"a": 1, "b": true, "c": null, "d": undefined}') as string).toBe(
|
|
160
|
-
'{"a": 1, "b": true, "c": null, "d": undefined}',
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("should parse nested objects", () => {
|
|
165
|
-
expect(parseString('{"user": {"name": "John", "age": 30}}') as object).toEqual({
|
|
166
|
-
user: { name: "John", age: 30 },
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("should parse objects with arrays", () => {
|
|
171
|
-
expect(parseString('{"numbers": [1, 2, 3]}') as object).toEqual({
|
|
172
|
-
numbers: [1, 2, 3],
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test("should return original string for malformed objects", () => {
|
|
177
|
-
expect(parseString("{invalid}") as string).toBe("{invalid}");
|
|
178
|
-
expect(parseString("{name: test}") as string).toBe("{name: test}");
|
|
179
|
-
expect(parseString('{"unclosed": ') as string).toBe('{"unclosed": ');
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe("JSON parsing fallback", () => {
|
|
184
|
-
test("should parse valid JSON strings", () => {
|
|
185
|
-
expect(parseString('"hello world"') as string).toBe("hello world");
|
|
186
|
-
expect(parseString('"123"') as string).toBe("123");
|
|
187
|
-
expect(parseString('""') as string).toBe("");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
test("should parse JSON numbers", () => {
|
|
191
|
-
expect(parseString("123") as number).toBe(123);
|
|
192
|
-
expect(parseString("123.45") as number).toBe(123.45);
|
|
193
|
-
expect(parseString("-123") as number).toBe(-123);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test("should handle special numeric values as strings", () => {
|
|
197
|
-
expect(parseString("Infinity") as string).toBe("Infinity");
|
|
198
|
-
expect(parseString("-Infinity") as string).toBe("-Infinity");
|
|
199
|
-
expect(parseString("NaN") as string).toBe("NaN");
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test("should handle JSON values that resolve to infinity", () => {
|
|
203
|
-
expect(parseString("1e999") as string).toBe("1e999");
|
|
204
|
-
expect(parseString("-1e999") as string).toBe("-1e999");
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe("string fallback", () => {
|
|
209
|
-
test("should return original string for unparseable values", () => {
|
|
210
|
-
expect(parseString("hello world") as string).toBe("hello world");
|
|
211
|
-
expect(parseString("123abc") as string).toBe("123abc");
|
|
212
|
-
expect(parseString("true123") as string).toBe("true123");
|
|
213
|
-
expect(parseString("null_value") as string).toBe("null_value");
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test("should handle strings with special characters", () => {
|
|
217
|
-
expect(parseString("hello@world.com") as string).toBe("hello@world.com");
|
|
218
|
-
expect(parseString("$100") as string).toBe("$100");
|
|
219
|
-
expect(parseString("50%") as string).toBe("50%");
|
|
220
|
-
expect(parseString("#tag") as string).toBe("#tag");
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
test("should handle multiline strings", () => {
|
|
224
|
-
const multiline = "line1\nline2\nline3";
|
|
225
|
-
expect(parseString(multiline) as string).toBe(multiline);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test("should handle strings with quotes", () => {
|
|
229
|
-
expect(parseString('say "hello"') as string).toBe('say "hello"');
|
|
230
|
-
expect(parseString("it's working") as string).toBe("it's working");
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
describe("edge cases", () => {
|
|
235
|
-
test("should handle whitespace-only strings", () => {
|
|
236
|
-
expect(parseString(" ") as string).toBe(" ");
|
|
237
|
-
expect(parseString(" ") as string).toBe(" ");
|
|
238
|
-
expect(parseString("\t") as string).toBe("\t");
|
|
239
|
-
expect(parseString("\n") as string).toBe("\n");
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
test("should handle strings that look like numbers but aren't", () => {
|
|
243
|
-
expect(parseString("123 ") as number).toBe(123);
|
|
244
|
-
expect(parseString(" 123") as number).toBe(123);
|
|
245
|
-
expect(parseString("12.34.56") as string).toBe("12.34.56");
|
|
246
|
-
expect(parseString("12..34") as string).toBe("12..34");
|
|
247
|
-
expect(parseString("--123") as string).toBe("--123");
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
test("should handle strings that partially match patterns", () => {
|
|
251
|
-
expect(parseString("truee") as string).toBe("truee");
|
|
252
|
-
expect(parseString("falsee") as string).toBe("falsee");
|
|
253
|
-
expect(parseString("nulll") as string).toBe("nulll");
|
|
254
|
-
expect(parseString("undefinedd") as string).toBe("undefinedd");
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("should handle Unicode characters", () => {
|
|
258
|
-
expect(parseString("café") as string).toBe("café");
|
|
259
|
-
expect(parseString("数字") as string).toBe("数字");
|
|
260
|
-
expect(parseString("🎉") as string).toBe("🎉");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("should handle very long strings", () => {
|
|
264
|
-
const longString = "a".repeat(1000);
|
|
265
|
-
expect(parseString(longString) as string).toBe(longString);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe("type inference", () => {
|
|
270
|
-
test("should maintain type inference with generic", () => {
|
|
271
|
-
const numberResult = parseString<number>("123");
|
|
272
|
-
expect(typeof numberResult).toBe("number");
|
|
273
|
-
expect(numberResult).toBe(123);
|
|
274
|
-
|
|
275
|
-
const stringResult = parseString<string>("hello");
|
|
276
|
-
expect(typeof stringResult).toBe("string");
|
|
277
|
-
expect(stringResult).toBe("hello");
|
|
278
|
-
|
|
279
|
-
const booleanResult = parseString<boolean>("true");
|
|
280
|
-
expect(typeof booleanResult).toBe("boolean");
|
|
281
|
-
expect(booleanResult).toBe(true);
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
describe("parametrized tests", () => {
|
|
286
|
-
test.each([
|
|
287
|
-
["0", 0],
|
|
288
|
-
["42", 42],
|
|
289
|
-
["-17", -17],
|
|
290
|
-
["3.14", 3.14],
|
|
291
|
-
["-2.5", -2.5],
|
|
292
|
-
["true", true],
|
|
293
|
-
["false", false],
|
|
294
|
-
["null", null],
|
|
295
|
-
["[1,2,3]", [1, 2, 3]],
|
|
296
|
-
["{}", {}],
|
|
297
|
-
['{"a":1}', { a: 1 }],
|
|
298
|
-
['"text"', "text"],
|
|
299
|
-
["hello", "hello"],
|
|
300
|
-
["1e3", 1000],
|
|
301
|
-
["2.5e-1", 0.25],
|
|
302
|
-
])("parseString(%s) should return %j", (input, expected) => {
|
|
303
|
-
expect(parseString(input) as unknown).toEqual(expected);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe("array splitting edge cases", () => {
|
|
308
|
-
test("should handle arrays with nested brackets", () => {
|
|
309
|
-
expect(parseString('["[test]", "{obj}"]') as string[]).toEqual(["test", "{obj}"]);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test("should handle arrays with escaped quotes", () => {
|
|
313
|
-
expect(parseString('["\\"hello\\"", "world"]') as string[]).toEqual(['"hello"', "world"]);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
test("should handle deeply nested structures", () => {
|
|
317
|
-
expect(parseString("[[[1,2],[3,4]],[[5,6],[7,8]]]") as number[]).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
describe("real world examples", () => {
|
|
322
|
-
test("should parse configuration values", () => {
|
|
323
|
-
expect(parseString("3000") as number).toBe(3000);
|
|
324
|
-
expect(parseString("true") as boolean).toBe(true);
|
|
325
|
-
expect(parseString("production") as string).toBe("production");
|
|
326
|
-
expect(parseString('["api", "web", "worker"]') as string[]).toEqual(["api", "web", "worker"]);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
test("should parse environment variables", () => {
|
|
330
|
-
expect(parseString("DEBUG") as string).toBe("DEBUG");
|
|
331
|
-
expect(parseString("1") as number).toBe(1);
|
|
332
|
-
expect(parseString("false") as boolean).toBe(false);
|
|
333
|
-
expect(parseString("null") as null).toBe(null);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test("should parse URL parameters", () => {
|
|
337
|
-
expect(parseString("page") as string).toBe("page");
|
|
338
|
-
expect(parseString("10") as number).toBe(10);
|
|
339
|
-
expect(parseString("true") as boolean).toBe(true);
|
|
340
|
-
expect(parseString("") as string).toBe("");
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
test("should parse form data", () => {
|
|
344
|
-
expect(parseString("John Doe") as string).toBe("John Doe");
|
|
345
|
-
expect(parseString("25") as number).toBe(25);
|
|
346
|
-
expect(parseString("on") as string).toBe("on");
|
|
347
|
-
expect(parseString("false") as boolean).toBe(false);
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
describe("performance and consistency", () => {
|
|
352
|
-
test("should handle consecutive calls consistently", () => {
|
|
353
|
-
const input = '{"test": [1, true, null]}';
|
|
354
|
-
const result1 = parseString(input);
|
|
355
|
-
const result2 = parseString(input);
|
|
356
|
-
expect(result1 as unknown).toEqual(result2 as unknown);
|
|
357
|
-
expect(result1 as unknown).toEqual({ test: [1, true, null] });
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
test("should not mutate input", () => {
|
|
361
|
-
const input = '{"mutable": false}';
|
|
362
|
-
const originalInput = input;
|
|
363
|
-
const result = parseString(input);
|
|
364
|
-
expect(input).toBe(originalInput);
|
|
365
|
-
expect(result as unknown).toEqual({ mutable: false });
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
test("should handle large arrays efficiently", () => {
|
|
369
|
-
const largeArray = `[${Array.from({ length: 100 }, (_, i) => i).join(",")}]`;
|
|
370
|
-
const result = parseString(largeArray) as number[];
|
|
371
|
-
expect(Array.isArray(result)).toBe(true);
|
|
372
|
-
expect(result).toHaveLength(100);
|
|
373
|
-
expect(result[0]).toBe(0);
|
|
374
|
-
expect(result[99]).toBe(99);
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
});
|