@holoscript/std 7.0.0 → 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.
- package/README.md +8 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/{chunk-PFX2JM4X.js → chunk-FAMOLKH3.js} +2 -1
- package/dist/{chunk-PFX2JM4X.js.map → chunk-FAMOLKH3.js.map} +1 -1
- package/dist/{chunk-DZHAVOCH.js → chunk-SOKH6FJ7.js} +31 -6
- package/dist/chunk-SOKH6FJ7.js.map +1 -0
- package/dist/collections.cjs +1 -0
- package/dist/collections.cjs.map +1 -1
- package/dist/collections.js +2 -2
- package/dist/fs/fs.d.ts.map +1 -1
- package/dist/fs/index.cjs +221 -8510
- package/dist/fs/index.cjs.map +1 -1
- package/dist/fs/index.js +832 -118
- package/dist/fs/index.js.map +1 -1
- package/dist/fs/sandbox.d.ts +49 -0
- package/dist/fs/sandbox.d.ts.map +1 -0
- package/dist/index.cjs +3494 -12672
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +18 -3
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +2 -2
- package/dist/string.js +1 -1
- package/dist/time.js +1 -1
- package/dist/traits/EconomicPrimitives.js +1 -1
- package/dist/traits/EconomicTraits.js +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -9
- package/dist/__tests__/EconomicPrimitives.test.d.ts +0 -2
- package/dist/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
- package/dist/__tests__/EconomicTraits.test.d.ts +0 -2
- package/dist/__tests__/EconomicTraits.test.d.ts.map +0 -1
- package/dist/__tests__/SimulationLabPrimitives.test.d.ts +0 -2
- package/dist/__tests__/SimulationLabPrimitives.test.d.ts.map +0 -1
- package/dist/__tests__/collections.test.d.ts +0 -2
- package/dist/__tests__/collections.test.d.ts.map +0 -1
- package/dist/__tests__/events.test.d.ts +0 -2
- package/dist/__tests__/events.test.d.ts.map +0 -1
- package/dist/__tests__/index.test.d.ts +0 -2
- package/dist/__tests__/index.test.d.ts.map +0 -1
- package/dist/__tests__/materials.test.d.ts +0 -2
- package/dist/__tests__/materials.test.d.ts.map +0 -1
- package/dist/__tests__/math.test.d.ts +0 -2
- package/dist/__tests__/math.test.d.ts.map +0 -1
- package/dist/__tests__/physics.test.d.ts +0 -2
- package/dist/__tests__/physics.test.d.ts.map +0 -1
- package/dist/__tests__/spatial.test.d.ts +0 -2
- package/dist/__tests__/spatial.test.d.ts.map +0 -1
- package/dist/__tests__/standard-library-fundamentals.test.d.ts +0 -2
- package/dist/__tests__/standard-library-fundamentals.test.d.ts.map +0 -1
- package/dist/__tests__/string-and-time-utilities.test.d.ts +0 -2
- package/dist/__tests__/string-and-time-utilities.test.d.ts.map +0 -1
- package/dist/__tests__/string-decoupled.test.d.ts +0 -2
- package/dist/__tests__/string-decoupled.test.d.ts.map +0 -1
- package/dist/__tests__/string.test.d.ts +0 -2
- package/dist/__tests__/string.test.d.ts.map +0 -1
- package/dist/__tests__/time.test.d.ts +0 -2
- package/dist/__tests__/time.test.d.ts.map +0 -1
- package/dist/chunk-DZHAVOCH.js.map +0 -1
- package/dist/chunk-PR4QN5HX.js +0 -43
- package/dist/chunk-XBA4ARST.js +0 -9313
- package/dist/chunk-XBA4ARST.js.map +0 -1
- package/dist/fs/__tests__/file-watch-system.test.d.ts +0 -2
- package/dist/fs/__tests__/file-watch-system.test.d.ts.map +0 -1
- package/dist/fs/__tests__/path-utilities.test.d.ts +0 -2
- package/dist/fs/__tests__/path-utilities.test.d.ts.map +0 -1
- package/dist/fs/__tests__/path.test.d.ts +0 -2
- package/dist/fs/__tests__/path.test.d.ts.map +0 -1
- package/dist/string.basic.test.d.ts +0 -5
- package/dist/string.basic.test.d.ts.map +0 -1
- package/dist/string.test.d.ts +0 -5
- package/dist/string.test.d.ts.map +0 -1
- package/dist/traits/__tests__/ARTraits.test.d.ts +0 -2
- package/dist/traits/__tests__/ARTraits.test.d.ts.map +0 -1
- package/dist/traits/__tests__/EconomicPrimitives.test.d.ts +0 -2
- package/dist/traits/__tests__/EconomicPrimitives.test.d.ts.map +0 -1
- package/dist/traits/__tests__/EconomicTraits.test.d.ts +0 -2
- package/dist/traits/__tests__/EconomicTraits.test.d.ts.map +0 -1
- package/error-utf8.log +0 -6
- package/error.log +0 -0
- package/src/__tests__/EconomicPrimitives.test.ts +0 -690
- package/src/__tests__/EconomicTraits.test.ts +0 -425
- package/src/__tests__/SimulationLabPrimitives.test.ts +0 -415
- package/src/__tests__/collections.test.ts +0 -182
- package/src/__tests__/events.test.ts +0 -135
- package/src/__tests__/index.test.ts +0 -14
- package/src/__tests__/materials.test.ts +0 -84
- package/src/__tests__/math.test.ts +0 -246
- package/src/__tests__/physics.test.ts +0 -83
- package/src/__tests__/spatial.test.ts +0 -333
- package/src/__tests__/standard-library-fundamentals.test.ts +0 -1318
- package/src/__tests__/string-and-time-utilities.test.ts +0 -1070
- package/src/__tests__/string-decoupled.test.ts +0 -13
- package/src/__tests__/string.test.ts +0 -164
- package/src/__tests__/time.test.ts +0 -110
- package/src/collections.ts +0 -850
- package/src/events.ts +0 -88
- package/src/fs/__tests__/file-watch-system.test.ts +0 -675
- package/src/fs/__tests__/path-utilities.test.ts +0 -375
- package/src/fs/__tests__/path.test.ts +0 -287
- package/src/fs/fs.ts +0 -692
- package/src/fs/index.ts +0 -194
- package/src/fs/path.ts +0 -310
- package/src/fs/watch.ts +0 -413
- package/src/index.ts +0 -476
- package/src/materials.ts +0 -109
- package/src/math.ts +0 -674
- package/src/physics.ts +0 -141
- package/src/spatial.ts +0 -320
- package/src/string.basic.test.ts +0 -14
- package/src/string.test.ts +0 -335
- package/src/string.ts +0 -531
- package/src/time.ts +0 -621
- package/src/traits/ARTraits.ts +0 -103
- package/src/traits/EconomicPrimitives.ts +0 -755
- package/src/traits/EconomicTraits.ts +0 -552
- package/src/traits/IoTTraits.ts +0 -102
- package/src/traits/SimulationLabPrimitives.ts +0 -650
- package/src/traits/SimulationLabTraits.ts +0 -191
- package/src/traits/VRRTraits.ts +0 -326
- package/src/traits/__tests__/ARTraits.test.ts +0 -8
- package/src/traits/__tests__/EconomicPrimitives.test.ts +0 -14
- package/src/traits/__tests__/EconomicTraits.test.ts +0 -16
- package/src/types.ts +0 -418
- package/std_error.log +0 -5
- package/tsconfig.json +0 -18
- package/tsup.config.ts +0 -20
- package/vitest.config.ts +0 -10
- /package/dist/{chunk-PR4QN5HX.js.map → chunk-DGUM43GV.js.map} +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import * as strings from '../string.js';
|
|
3
|
-
|
|
4
|
-
describe('string-decoupled', () => {
|
|
5
|
-
it('should export basic string utilities', () => {
|
|
6
|
-
expect(strings.capitalize).toBeDefined();
|
|
7
|
-
expect(strings.capitalize('hello')).toBe('Hello');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should handle whitespace utilities', () => {
|
|
11
|
-
expect(strings.removeWhitespace(' h e l l o ')).toBe('hello');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
isBlank,
|
|
4
|
-
isNotBlank,
|
|
5
|
-
capitalize,
|
|
6
|
-
titleCase,
|
|
7
|
-
camelCase,
|
|
8
|
-
pascalCase,
|
|
9
|
-
snakeCase,
|
|
10
|
-
kebabCase,
|
|
11
|
-
constantCase,
|
|
12
|
-
} from '../string.js';
|
|
13
|
-
|
|
14
|
-
describe('isBlank', () => {
|
|
15
|
-
it('should return true for empty string', () => {
|
|
16
|
-
expect(isBlank('')).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should return true for whitespace only', () => {
|
|
20
|
-
expect(isBlank(' ')).toBe(true);
|
|
21
|
-
expect(isBlank('\t\n')).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should return false for non-empty string', () => {
|
|
25
|
-
expect(isBlank('hello')).toBe(false);
|
|
26
|
-
expect(isBlank(' hello ')).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('isNotBlank', () => {
|
|
31
|
-
it('should return false for empty string', () => {
|
|
32
|
-
expect(isNotBlank('')).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should return false for whitespace only', () => {
|
|
36
|
-
expect(isNotBlank(' ')).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return true for non-empty string', () => {
|
|
40
|
-
expect(isNotBlank('hello')).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('capitalize', () => {
|
|
45
|
-
it('should capitalize first letter', () => {
|
|
46
|
-
expect(capitalize('hello')).toBe('Hello');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should handle empty string', () => {
|
|
50
|
-
expect(capitalize('')).toBe('');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should handle already capitalized', () => {
|
|
54
|
-
expect(capitalize('Hello')).toBe('Hello');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should handle single character', () => {
|
|
58
|
-
expect(capitalize('a')).toBe('A');
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('titleCase', () => {
|
|
63
|
-
it('should capitalize each word', () => {
|
|
64
|
-
expect(titleCase('hello world')).toBe('Hello World');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should handle multiple spaces', () => {
|
|
68
|
-
expect(titleCase('hello world')).toBe('Hello World');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should handle single word', () => {
|
|
72
|
-
expect(titleCase('hello')).toBe('Hello');
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('camelCase', () => {
|
|
77
|
-
it('should convert space-separated to camelCase', () => {
|
|
78
|
-
expect(camelCase('hello world')).toBe('helloWorld');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should convert kebab-case to camelCase', () => {
|
|
82
|
-
expect(camelCase('hello-world')).toBe('helloWorld');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should convert snake_case to camelCase', () => {
|
|
86
|
-
expect(camelCase('hello_world')).toBe('helloWorld');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should lowercase first letter of PascalCase', () => {
|
|
90
|
-
expect(camelCase('HelloWorld')).toBe('helloWorld');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should handle empty string', () => {
|
|
94
|
-
expect(camelCase('')).toBe('');
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('pascalCase', () => {
|
|
99
|
-
it('should convert space-separated to PascalCase', () => {
|
|
100
|
-
expect(pascalCase('hello world')).toBe('HelloWorld');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should convert kebab-case to PascalCase', () => {
|
|
104
|
-
expect(pascalCase('hello-world')).toBe('HelloWorld');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should convert snake_case to PascalCase', () => {
|
|
108
|
-
expect(pascalCase('hello_world')).toBe('HelloWorld');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should handle empty string', () => {
|
|
112
|
-
expect(pascalCase('')).toBe('');
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('snakeCase', () => {
|
|
117
|
-
it('should convert space-separated to snake_case', () => {
|
|
118
|
-
expect(snakeCase('hello world')).toBe('hello_world');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should convert camelCase to snake_case', () => {
|
|
122
|
-
expect(snakeCase('helloWorld')).toBe('hello_world');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should convert PascalCase to snake_case', () => {
|
|
126
|
-
expect(snakeCase('HelloWorld')).toBe('hello_world');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should convert kebab-case to snake_case', () => {
|
|
130
|
-
expect(snakeCase('hello-world')).toBe('hello_world');
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('kebabCase', () => {
|
|
135
|
-
it('should convert space-separated to kebab-case', () => {
|
|
136
|
-
expect(kebabCase('hello world')).toBe('hello-world');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should convert camelCase to kebab-case', () => {
|
|
140
|
-
expect(kebabCase('helloWorld')).toBe('hello-world');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('should convert PascalCase to kebab-case', () => {
|
|
144
|
-
expect(kebabCase('HelloWorld')).toBe('hello-world');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should convert snake_case to kebab-case', () => {
|
|
148
|
-
expect(kebabCase('hello_world')).toBe('hello-world');
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe('constantCase', () => {
|
|
153
|
-
it('should convert to SCREAMING_SNAKE_CASE', () => {
|
|
154
|
-
expect(constantCase('hello world')).toBe('HELLO_WORLD');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('should convert camelCase to SCREAMING_SNAKE_CASE', () => {
|
|
158
|
-
expect(constantCase('helloWorld')).toBe('HELLO_WORLD');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('should convert kebab-case to SCREAMING_SNAKE_CASE', () => {
|
|
162
|
-
expect(constantCase('hello-world')).toBe('HELLO_WORLD');
|
|
163
|
-
});
|
|
164
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { now, hrTime, sleep, withTimeout } from '../time.js';
|
|
3
|
-
|
|
4
|
-
describe('now', () => {
|
|
5
|
-
it('should return current timestamp in milliseconds', () => {
|
|
6
|
-
const before = Date.now();
|
|
7
|
-
const result = now();
|
|
8
|
-
const after = Date.now();
|
|
9
|
-
|
|
10
|
-
expect(result).toBeGreaterThanOrEqual(before);
|
|
11
|
-
expect(result).toBeLessThanOrEqual(after);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should return a number', () => {
|
|
15
|
-
expect(typeof now()).toBe('number');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('hrTime', () => {
|
|
20
|
-
it('should return high-resolution timestamp', () => {
|
|
21
|
-
const result = hrTime();
|
|
22
|
-
expect(typeof result).toBe('number');
|
|
23
|
-
expect(result).toBeGreaterThanOrEqual(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should increase over time', async () => {
|
|
27
|
-
const t1 = hrTime();
|
|
28
|
-
await sleep(10);
|
|
29
|
-
const t2 = hrTime();
|
|
30
|
-
expect(t2).toBeGreaterThan(t1);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('sleep', () => {
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
vi.useFakeTimers();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
afterEach(() => {
|
|
40
|
-
vi.useRealTimers();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should return a promise', () => {
|
|
44
|
-
const result = sleep(100);
|
|
45
|
-
expect(result).toBeInstanceOf(Promise);
|
|
46
|
-
vi.runAllTimers();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should resolve after specified time', async () => {
|
|
50
|
-
let resolved = false;
|
|
51
|
-
const promise = sleep(1000).then(() => {
|
|
52
|
-
resolved = true;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(resolved).toBe(false);
|
|
56
|
-
|
|
57
|
-
vi.advanceTimersByTime(500);
|
|
58
|
-
await Promise.resolve();
|
|
59
|
-
expect(resolved).toBe(false);
|
|
60
|
-
|
|
61
|
-
vi.advanceTimersByTime(500);
|
|
62
|
-
await promise;
|
|
63
|
-
expect(resolved).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('withTimeout', () => {
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
vi.useFakeTimers();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
afterEach(() => {
|
|
73
|
-
vi.useRealTimers();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should resolve if function completes before timeout', async () => {
|
|
77
|
-
const fn = async () => {
|
|
78
|
-
await sleep(50);
|
|
79
|
-
return 'success';
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const promise = withTimeout(fn, 1000);
|
|
83
|
-
vi.advanceTimersByTime(50);
|
|
84
|
-
await vi.runAllTimersAsync();
|
|
85
|
-
|
|
86
|
-
const result = await promise;
|
|
87
|
-
expect(result).toBe('success');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should reject with Timeout error if function takes too long', async () => {
|
|
91
|
-
const fn = async () => {
|
|
92
|
-
await sleep(2000);
|
|
93
|
-
return 'success';
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const promise = withTimeout(fn, 100);
|
|
97
|
-
vi.advanceTimersByTime(100);
|
|
98
|
-
|
|
99
|
-
await expect(promise).rejects.toThrow('Timeout');
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('time utilities - real timers', () => {
|
|
104
|
-
it('sleep should actually wait (short duration)', async () => {
|
|
105
|
-
const start = Date.now();
|
|
106
|
-
await sleep(50);
|
|
107
|
-
const elapsed = Date.now() - start;
|
|
108
|
-
expect(elapsed).toBeGreaterThanOrEqual(40); // Allow some tolerance
|
|
109
|
-
});
|
|
110
|
-
});
|