@holoscript/std 6.0.3 → 7.0.1

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 (128) hide show
  1. package/README.md +8 -0
  2. package/dist/chunk-DGUM43GV.js +11 -0
  3. package/dist/chunk-DGUM43GV.js.map +1 -0
  4. package/dist/{chunk-PFX2JM4X.js → chunk-FAMOLKH3.js} +2 -1
  5. package/dist/{chunk-PFX2JM4X.js.map → chunk-FAMOLKH3.js.map} +1 -1
  6. package/dist/{chunk-7HVUYGPS.js → chunk-SOKH6FJ7.js} +37 -5
  7. package/dist/chunk-SOKH6FJ7.js.map +1 -0
  8. package/dist/{chunk-W2Q3LUCM.js → chunk-XJIFG7G3.js} +3 -3
  9. package/dist/chunk-XJIFG7G3.js.map +1 -0
  10. package/dist/collections.cjs +1 -0
  11. package/dist/collections.cjs.map +1 -1
  12. package/dist/collections.js +2 -1
  13. package/dist/fs/fs.d.ts +288 -0
  14. package/dist/fs/fs.d.ts.map +1 -0
  15. package/dist/fs/index.cjs +1049 -0
  16. package/dist/fs/index.cjs.map +1 -0
  17. package/dist/fs/index.d.ts +51 -0
  18. package/dist/fs/index.d.ts.map +1 -0
  19. package/dist/fs/index.js +918 -0
  20. package/dist/fs/index.js.map +1 -0
  21. package/dist/fs/path.d.ts +135 -0
  22. package/dist/fs/path.d.ts.map +1 -0
  23. package/dist/fs/sandbox.d.ts +49 -0
  24. package/dist/fs/sandbox.d.ts.map +1 -0
  25. package/dist/fs/watch.d.ts +133 -0
  26. package/dist/fs/watch.d.ts.map +1 -0
  27. package/dist/index.cjs +54 -7
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +19 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/math.cjs +21 -2
  32. package/dist/math.cjs.map +1 -1
  33. package/dist/math.js +2 -1
  34. package/dist/string.cjs +2 -2
  35. package/dist/string.cjs.map +1 -1
  36. package/dist/string.js +2 -1
  37. package/dist/time.js +1 -0
  38. package/dist/traits/EconomicPrimitives.js +1 -0
  39. package/dist/traits/EconomicTraits.js +1 -0
  40. package/dist/traits/VRRTraits.d.ts +2 -2
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +24 -9
  43. package/CHANGELOG.md +0 -7
  44. package/dist/__tests__/EconomicPrimitives.test.d.ts +0 -2
  45. package/dist/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
  46. package/dist/__tests__/EconomicTraits.test.d.ts +0 -2
  47. package/dist/__tests__/EconomicTraits.test.d.ts.map +0 -1
  48. package/dist/__tests__/SimulationLabPrimitives.test.d.ts +0 -2
  49. package/dist/__tests__/SimulationLabPrimitives.test.d.ts.map +0 -1
  50. package/dist/__tests__/collections.test.d.ts +0 -2
  51. package/dist/__tests__/collections.test.d.ts.map +0 -1
  52. package/dist/__tests__/events.test.d.ts +0 -2
  53. package/dist/__tests__/events.test.d.ts.map +0 -1
  54. package/dist/__tests__/index.test.d.ts +0 -2
  55. package/dist/__tests__/index.test.d.ts.map +0 -1
  56. package/dist/__tests__/materials.test.d.ts +0 -2
  57. package/dist/__tests__/materials.test.d.ts.map +0 -1
  58. package/dist/__tests__/math.test.d.ts +0 -2
  59. package/dist/__tests__/math.test.d.ts.map +0 -1
  60. package/dist/__tests__/physics.test.d.ts +0 -2
  61. package/dist/__tests__/physics.test.d.ts.map +0 -1
  62. package/dist/__tests__/spatial.test.d.ts +0 -2
  63. package/dist/__tests__/spatial.test.d.ts.map +0 -1
  64. package/dist/__tests__/standard-library-fundamentals.test.d.ts +0 -2
  65. package/dist/__tests__/standard-library-fundamentals.test.d.ts.map +0 -1
  66. package/dist/__tests__/string-and-time-utilities.test.d.ts +0 -2
  67. package/dist/__tests__/string-and-time-utilities.test.d.ts.map +0 -1
  68. package/dist/__tests__/string-decoupled.test.d.ts +0 -2
  69. package/dist/__tests__/string-decoupled.test.d.ts.map +0 -1
  70. package/dist/__tests__/string.test.d.ts +0 -2
  71. package/dist/__tests__/string.test.d.ts.map +0 -1
  72. package/dist/__tests__/time.test.d.ts +0 -2
  73. package/dist/__tests__/time.test.d.ts.map +0 -1
  74. package/dist/chunk-7HVUYGPS.js.map +0 -1
  75. package/dist/chunk-W2Q3LUCM.js.map +0 -1
  76. package/dist/string.basic.test.d.ts +0 -5
  77. package/dist/string.basic.test.d.ts.map +0 -1
  78. package/dist/string.test.d.ts +0 -5
  79. package/dist/string.test.d.ts.map +0 -1
  80. package/dist/traits/__tests__/ARTraits.test.d.ts +0 -2
  81. package/dist/traits/__tests__/ARTraits.test.d.ts.map +0 -1
  82. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts +0 -2
  83. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
  84. package/dist/traits/__tests__/EconomicTraits.test.d.ts +0 -2
  85. package/dist/traits/__tests__/EconomicTraits.test.d.ts.map +0 -1
  86. package/error-utf8.log +0 -6
  87. package/error.log +0 -0
  88. package/src/__tests__/EconomicPrimitives.test.ts +0 -690
  89. package/src/__tests__/EconomicTraits.test.ts +0 -425
  90. package/src/__tests__/SimulationLabPrimitives.test.ts +0 -415
  91. package/src/__tests__/collections.test.ts +0 -182
  92. package/src/__tests__/events.test.ts +0 -135
  93. package/src/__tests__/index.test.ts +0 -14
  94. package/src/__tests__/materials.test.ts +0 -84
  95. package/src/__tests__/math.test.ts +0 -246
  96. package/src/__tests__/physics.test.ts +0 -83
  97. package/src/__tests__/spatial.test.ts +0 -333
  98. package/src/__tests__/standard-library-fundamentals.test.ts +0 -1301
  99. package/src/__tests__/string-and-time-utilities.test.ts +0 -1070
  100. package/src/__tests__/string-decoupled.test.ts +0 -14
  101. package/src/__tests__/string.test.ts +0 -164
  102. package/src/__tests__/time.test.ts +0 -110
  103. package/src/collections.ts +0 -850
  104. package/src/events.ts +0 -88
  105. package/src/index.ts +0 -474
  106. package/src/materials.ts +0 -109
  107. package/src/math.ts +0 -674
  108. package/src/physics.ts +0 -141
  109. package/src/spatial.ts +0 -320
  110. package/src/string.basic.test.ts +0 -14
  111. package/src/string.test.ts +0 -335
  112. package/src/string.ts +0 -531
  113. package/src/time.ts +0 -621
  114. package/src/traits/ARTraits.ts +0 -103
  115. package/src/traits/EconomicPrimitives.ts +0 -755
  116. package/src/traits/EconomicTraits.ts +0 -552
  117. package/src/traits/IoTTraits.ts +0 -102
  118. package/src/traits/SimulationLabPrimitives.ts +0 -650
  119. package/src/traits/SimulationLabTraits.ts +0 -191
  120. package/src/traits/VRRTraits.ts +0 -326
  121. package/src/traits/__tests__/ARTraits.test.ts +0 -14
  122. package/src/traits/__tests__/EconomicPrimitives.test.ts +0 -14
  123. package/src/traits/__tests__/EconomicTraits.test.ts +0 -14
  124. package/src/types.ts +0 -411
  125. package/std_error.log +0 -5
  126. package/tsconfig.json +0 -18
  127. package/tsup.config.ts +0 -17
  128. package/vitest.config.ts +0 -10
@@ -1,335 +0,0 @@
1
- /**
2
- * @fileoverview Comprehensive tests for @holoscript/std string utilities
3
- */
4
-
5
- import { describe, it, expect } from 'vitest';
6
- import {
7
- isBlank,
8
- isNotBlank,
9
- capitalize,
10
- titleCase,
11
- camelCase,
12
- pascalCase,
13
- snakeCase,
14
- kebabCase,
15
- constantCase,
16
- padLeft,
17
- padRight,
18
- center,
19
- truncate,
20
- truncateMiddle,
21
- repeat,
22
- reverse,
23
- count,
24
- containsIgnoreCase,
25
- startsWithIgnoreCase,
26
- endsWithIgnoreCase,
27
- removeWhitespace,
28
- collapseWhitespace,
29
- removePrefix,
30
- removeSuffix,
31
- wrap,
32
- unwrap,
33
- lines,
34
- words,
35
- chars,
36
- join,
37
- format,
38
- formatNumber,
39
- numberWithCommas,
40
- formatBytes,
41
- formatDuration,
42
- escapeHtml,
43
- unescapeHtml,
44
- escapeRegex,
45
- slugify,
46
- isValidIdentifier,
47
- isNumeric,
48
- isAlphanumeric,
49
- isAlpha,
50
- randomString,
51
- uuid,
52
- indent,
53
- dedent,
54
- wordWrap,
55
- levenshtein,
56
- similarity,
57
- extractTraits,
58
- } from './string.js';
59
-
60
- describe('@holoscript/std string utilities', () => {
61
- describe('formatBytes', () => {
62
- it('should format bytes correctly with default 2 decimals', () => {
63
- expect(formatBytes(0)).toBe('0 B');
64
- expect(formatBytes(100)).toBe('100 B');
65
- expect(formatBytes(1023)).toBe('1023 B');
66
- expect(formatBytes(1024)).toBe('1 KB');
67
- expect(formatBytes(1536)).toBe('1.5 KB');
68
- expect(formatBytes(1048576)).toBe('1 MB');
69
- expect(formatBytes(1073741824)).toBe('1 GB');
70
- expect(formatBytes(1099511627776)).toBe('1 TB');
71
- });
72
-
73
- it('should respect custom decimal precision', () => {
74
- expect(formatBytes(1536, 0)).toBe('2 KB');
75
- expect(formatBytes(1536, 1)).toBe('1.5 KB');
76
- expect(formatBytes(1536, 3)).toBe('1.5 KB');
77
- expect(formatBytes(1677721, 3)).toBe('1.6 MB');
78
- });
79
-
80
- it('should handle edge cases', () => {
81
- expect(formatBytes(1)).toBe('1 B');
82
- expect(formatBytes(1025)).toBe('1 KB');
83
- expect(formatBytes(-100)).toBe('-100 B');
84
- });
85
-
86
- it('should handle very large numbers', () => {
87
- expect(formatBytes(1125899906842624)).toBe('1 PB'); // 1 petabyte
88
- expect(formatBytes(2251799813685248)).toBe('2 PB');
89
- });
90
- });
91
-
92
- describe('formatDuration', () => {
93
- it('should format milliseconds correctly', () => {
94
- expect(formatDuration(0)).toBe('0ms');
95
- expect(formatDuration(100)).toBe('100ms');
96
- expect(formatDuration(999)).toBe('999ms');
97
- });
98
-
99
- it('should format seconds correctly', () => {
100
- expect(formatDuration(1000)).toBe('1.0s');
101
- expect(formatDuration(1500)).toBe('1.5s');
102
- expect(formatDuration(59999)).toBe('60.0s');
103
- });
104
-
105
- it('should format minutes correctly', () => {
106
- expect(formatDuration(60000)).toBe('1.0m');
107
- expect(formatDuration(90000)).toBe('1.5m');
108
- expect(formatDuration(3599999)).toBe('60.0m');
109
- });
110
-
111
- it('should format hours correctly', () => {
112
- expect(formatDuration(3600000)).toBe('1.0h');
113
- expect(formatDuration(5400000)).toBe('1.5h');
114
- });
115
- });
116
-
117
- describe('case conversion', () => {
118
- const testString = 'hello world test';
119
-
120
- it('capitalize should capitalize first letter', () => {
121
- expect(capitalize('')).toBe('');
122
- expect(capitalize('hello')).toBe('Hello');
123
- expect(capitalize(testString)).toBe('Hello world test');
124
- });
125
-
126
- it('titleCase should capitalize each word', () => {
127
- expect(titleCase(testString)).toBe('Hello World Test');
128
- expect(titleCase('')).toBe('');
129
- expect(titleCase('a')).toBe('A');
130
- });
131
-
132
- it('camelCase should convert to camelCase', () => {
133
- expect(camelCase(testString)).toBe('helloWorldTest');
134
- expect(camelCase('Hello World')).toBe('helloWorld');
135
- expect(camelCase('')).toBe('');
136
- });
137
-
138
- it('pascalCase should convert to PascalCase', () => {
139
- expect(pascalCase(testString)).toBe('HelloWorldTest');
140
- expect(pascalCase('hello world')).toBe('HelloWorld');
141
- expect(pascalCase('')).toBe('');
142
- });
143
-
144
- it('snakeCase should convert to snake_case', () => {
145
- expect(snakeCase(testString)).toBe('hello_world_test');
146
- expect(snakeCase('HelloWorld')).toBe('hello_world');
147
- expect(snakeCase('')).toBe('');
148
- });
149
-
150
- it('kebabCase should convert to kebab-case', () => {
151
- expect(kebabCase(testString)).toBe('hello-world-test');
152
- expect(kebabCase('HelloWorld')).toBe('hello-world');
153
- expect(kebabCase('')).toBe('');
154
- });
155
-
156
- it('constantCase should convert to CONSTANT_CASE', () => {
157
- expect(constantCase(testString)).toBe('HELLO_WORLD_TEST');
158
- expect(constantCase('HelloWorld')).toBe('HELLO_WORLD');
159
- expect(constantCase('')).toBe('');
160
- });
161
- });
162
-
163
- describe('padding and alignment', () => {
164
- it('padLeft should pad on the left', () => {
165
- expect(padLeft('test', 8)).toBe(' test');
166
- expect(padLeft('test', 8, '*')).toBe('****test');
167
- expect(padLeft('test', 2)).toBe('test'); // No padding if already long enough
168
- });
169
-
170
- it('padRight should pad on the right', () => {
171
- expect(padRight('test', 8)).toBe('test ');
172
- expect(padRight('test', 8, '*')).toBe('test****');
173
- expect(padRight('test', 2)).toBe('test');
174
- });
175
-
176
- it('center should center text', () => {
177
- expect(center('test', 8)).toBe(' test ');
178
- expect(center('test', 9)).toBe(' test ');
179
- expect(center('test', 8, '*')).toBe('**test**');
180
- });
181
- });
182
-
183
- describe('validation functions', () => {
184
- describe('isBlank/isNotBlank', () => {
185
- it('should detect blank strings', () => {
186
- expect(isBlank('')).toBe(true);
187
- expect(isBlank(' ')).toBe(true);
188
- expect(isBlank('\t\n')).toBe(true);
189
- expect(isBlank('test')).toBe(false);
190
-
191
- expect(isNotBlank('')).toBe(false);
192
- expect(isNotBlank(' ')).toBe(false);
193
- expect(isNotBlank('test')).toBe(true);
194
- });
195
- });
196
-
197
- it('isValidIdentifier should validate identifiers', () => {
198
- expect(isValidIdentifier('validName')).toBe(true);
199
- expect(isValidIdentifier('_validName')).toBe(true);
200
- expect(isValidIdentifier('$validName')).toBe(true);
201
- expect(isValidIdentifier('123invalid')).toBe(false);
202
- expect(isValidIdentifier('invalid-name')).toBe(false);
203
- expect(isValidIdentifier('')).toBe(false);
204
- });
205
-
206
- it('isNumeric should validate numeric strings', () => {
207
- expect(isNumeric('123')).toBe(true);
208
- expect(isNumeric('123.45')).toBe(true);
209
- expect(isNumeric('-123')).toBe(true);
210
- expect(isNumeric('abc')).toBe(false);
211
- expect(isNumeric('')).toBe(false);
212
- });
213
-
214
- it('isAlphanumeric should validate alphanumeric strings', () => {
215
- expect(isAlphanumeric('abc123')).toBe(true);
216
- expect(isAlphanumeric('ABC')).toBe(true);
217
- expect(isAlphanumeric('123')).toBe(true);
218
- expect(isAlphanumeric('abc-123')).toBe(false);
219
- expect(isAlphanumeric('')).toBe(false);
220
- });
221
-
222
- it('isAlpha should validate alphabetic strings', () => {
223
- expect(isAlpha('abc')).toBe(true);
224
- expect(isAlpha('ABC')).toBe(true);
225
- expect(isAlpha('abc123')).toBe(false);
226
- expect(isAlpha('')).toBe(false);
227
- });
228
- });
229
-
230
- describe('string manipulation', () => {
231
- it('truncate should truncate with ellipsis', () => {
232
- expect(truncate('hello world', 5)).toBe('he...');
233
- expect(truncate('hello', 10)).toBe('hello');
234
- expect(truncate('hello world', 8, '---')).toBe('hello---');
235
- });
236
-
237
- it('truncateMiddle should truncate in middle', () => {
238
- expect(truncateMiddle('hello world test', 10)).toBe('hel...test');
239
- expect(truncateMiddle('short', 10)).toBe('short');
240
- });
241
-
242
- it('repeat should repeat strings', () => {
243
- expect(repeat('abc', 3)).toBe('abcabcabc');
244
- expect(repeat('x', 0)).toBe('');
245
- expect(repeat('', 5)).toBe('');
246
- });
247
-
248
- it('reverse should reverse strings', () => {
249
- expect(reverse('hello')).toBe('olleh');
250
- expect(reverse('')).toBe('');
251
- expect(reverse('a')).toBe('a');
252
- });
253
- });
254
-
255
- describe('HTML utilities', () => {
256
- it('escapeHtml should escape HTML entities', () => {
257
- expect(escapeHtml('<div>test</div>')).toBe('&lt;div&gt;test&lt;/div&gt;');
258
- expect(escapeHtml('a & b')).toBe('a &amp; b');
259
- expect(escapeHtml('"quoted"')).toBe('&quot;quoted&quot;');
260
- });
261
-
262
- it('unescapeHtml should unescape HTML entities', () => {
263
- expect(unescapeHtml('&lt;div&gt;test&lt;/div&gt;')).toBe('<div>test</div>');
264
- expect(unescapeHtml('a &amp; b')).toBe('a & b');
265
- expect(unescapeHtml('&quot;quoted&quot;')).toBe('"quoted"');
266
- });
267
- });
268
-
269
- describe('utility functions', () => {
270
- it('count should count substring occurrences', () => {
271
- expect(count('hello world hello', 'hello')).toBe(2);
272
- expect(count('aaa', 'aa')).toBe(2); // Overlapping matches
273
- expect(count('test', 'xyz')).toBe(0);
274
- });
275
-
276
- it('uuid should generate valid UUIDs', () => {
277
- const id1 = uuid();
278
- const id2 = uuid();
279
- expect(id1).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
280
- expect(id2).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
281
- expect(id1).not.toBe(id2); // Should be unique
282
- });
283
-
284
- it('randomString should generate random strings', () => {
285
- const str1 = randomString(10);
286
- const str2 = randomString(10);
287
- expect(str1.length).toBe(10);
288
- expect(str2.length).toBe(10);
289
- expect(str1).not.toBe(str2); // Should be different
290
-
291
- const customStr = randomString(5, 'ABC');
292
- expect(customStr.length).toBe(5);
293
- expect(customStr).toMatch(/^[ABC]+$/);
294
- });
295
-
296
- it('levenshtein should calculate edit distance', () => {
297
- expect(levenshtein('', '')).toBe(0);
298
- expect(levenshtein('hello', 'hello')).toBe(0);
299
- expect(levenshtein('hello', 'helo')).toBe(1);
300
- expect(levenshtein('kitten', 'sitting')).toBe(3);
301
- });
302
-
303
- it('similarity should calculate similarity score', () => {
304
- expect(similarity('hello', 'hello')).toBe(1);
305
- expect(similarity('', '')).toBe(1);
306
- expect(similarity('hello', 'world')).toBeLessThan(0.5);
307
- expect(similarity('hello', 'helo')).toBeGreaterThan(0.8);
308
- });
309
- });
310
-
311
- describe('format utilities', () => {
312
- it('numberWithCommas should add commas to numbers', () => {
313
- expect(numberWithCommas(1000)).toBe('1,000');
314
- expect(numberWithCommas(1234567)).toBe('1,234,567');
315
- expect(numberWithCommas(100)).toBe('100');
316
- });
317
-
318
- it('format should template strings', () => {
319
- expect(format('Hello {name}!', { name: 'World' })).toBe('Hello World!');
320
- expect(format('{a} + {b} = {sum}', { a: 1, b: 2, sum: 3 })).toBe('1 + 2 = 3');
321
- });
322
- });
323
-
324
- describe('extractTraits', () => {
325
- it('should extract trait syntax from code', () => {
326
- const code = `
327
- <Entity position="[1,2,3]" rotation="[0,0,0,1]">
328
- <Cube color="#ff0000" />
329
- </Entity>
330
- `;
331
- const traits = extractTraits(code);
332
- expect(traits).toEqual(['Entity', 'Cube']);
333
- });
334
- });
335
- });