@elaraai/east-web-std 1.0.85
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/CLA.md +26 -0
- package/CONTRIBUTING.md +28 -0
- package/LICENSE.md +31 -0
- package/README.md +191 -0
- package/THIRD_PARTY_NOTICES.md +123 -0
- package/dist/src/compliance.spec.d.ts +6 -0
- package/dist/src/compliance.spec.d.ts.map +1 -0
- package/dist/src/compliance.spec.js +89 -0
- package/dist/src/compliance.spec.js.map +1 -0
- package/dist/src/console.d.ts +237 -0
- package/dist/src/console.d.ts.map +1 -0
- package/dist/src/console.js +260 -0
- package/dist/src/console.js.map +1 -0
- package/dist/src/crypto.d.ts +224 -0
- package/dist/src/crypto.d.ts.map +1 -0
- package/dist/src/crypto.js +295 -0
- package/dist/src/crypto.js.map +1 -0
- package/dist/src/fetch.d.ts +383 -0
- package/dist/src/fetch.d.ts.map +1 -0
- package/dist/src/fetch.js +412 -0
- package/dist/src/fetch.js.map +1 -0
- package/dist/src/index.d.ts +106 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +93 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/path.d.ts +243 -0
- package/dist/src/path.d.ts.map +1 -0
- package/dist/src/path.js +562 -0
- package/dist/src/path.js.map +1 -0
- package/dist/src/random/crypto-rng.d.ts +38 -0
- package/dist/src/random/crypto-rng.d.ts.map +1 -0
- package/dist/src/random/crypto-rng.js +55 -0
- package/dist/src/random/crypto-rng.js.map +1 -0
- package/dist/src/random/distributions/bates.d.ts +17 -0
- package/dist/src/random/distributions/bates.d.ts.map +1 -0
- package/dist/src/random/distributions/bates.js +15 -0
- package/dist/src/random/distributions/bates.js.map +1 -0
- package/dist/src/random/distributions/bernoulli.d.ts +17 -0
- package/dist/src/random/distributions/bernoulli.d.ts.map +1 -0
- package/dist/src/random/distributions/bernoulli.js +13 -0
- package/dist/src/random/distributions/bernoulli.js.map +1 -0
- package/dist/src/random/distributions/binomial.d.ts +17 -0
- package/dist/src/random/distributions/binomial.d.ts.map +1 -0
- package/dist/src/random/distributions/binomial.js +24 -0
- package/dist/src/random/distributions/binomial.js.map +1 -0
- package/dist/src/random/distributions/exponential.d.ts +17 -0
- package/dist/src/random/distributions/exponential.d.ts.map +1 -0
- package/dist/src/random/distributions/exponential.js +13 -0
- package/dist/src/random/distributions/exponential.js.map +1 -0
- package/dist/src/random/distributions/geometric.d.ts +17 -0
- package/dist/src/random/distributions/geometric.d.ts.map +1 -0
- package/dist/src/random/distributions/geometric.js +14 -0
- package/dist/src/random/distributions/geometric.js.map +1 -0
- package/dist/src/random/distributions/irwin-hall.d.ts +17 -0
- package/dist/src/random/distributions/irwin-hall.d.ts.map +1 -0
- package/dist/src/random/distributions/irwin-hall.js +18 -0
- package/dist/src/random/distributions/irwin-hall.js.map +1 -0
- package/dist/src/random/distributions/log-normal.d.ts +17 -0
- package/dist/src/random/distributions/log-normal.d.ts.map +1 -0
- package/dist/src/random/distributions/log-normal.js +12 -0
- package/dist/src/random/distributions/log-normal.js.map +1 -0
- package/dist/src/random/distributions/normal.d.ts +18 -0
- package/dist/src/random/distributions/normal.d.ts.map +1 -0
- package/dist/src/random/distributions/normal.js +16 -0
- package/dist/src/random/distributions/normal.js.map +1 -0
- package/dist/src/random/distributions/pareto.d.ts +17 -0
- package/dist/src/random/distributions/pareto.d.ts.map +1 -0
- package/dist/src/random/distributions/pareto.js +14 -0
- package/dist/src/random/distributions/pareto.js.map +1 -0
- package/dist/src/random/distributions/poisson.d.ts +17 -0
- package/dist/src/random/distributions/poisson.d.ts.map +1 -0
- package/dist/src/random/distributions/poisson.js +81 -0
- package/dist/src/random/distributions/poisson.js.map +1 -0
- package/dist/src/random/distributions/uniform-int.d.ts +17 -0
- package/dist/src/random/distributions/uniform-int.d.ts.map +1 -0
- package/dist/src/random/distributions/uniform-int.js +16 -0
- package/dist/src/random/distributions/uniform-int.js.map +1 -0
- package/dist/src/random/distributions/uniform.d.ts +17 -0
- package/dist/src/random/distributions/uniform.d.ts.map +1 -0
- package/dist/src/random/distributions/uniform.js +10 -0
- package/dist/src/random/distributions/uniform.js.map +1 -0
- package/dist/src/random/rng.d.ts +21 -0
- package/dist/src/random/rng.d.ts.map +1 -0
- package/dist/src/random/rng.js +7 -0
- package/dist/src/random/rng.js.map +1 -0
- package/dist/src/random/xorshift128.d.ts +42 -0
- package/dist/src/random/xorshift128.d.ts.map +1 -0
- package/dist/src/random/xorshift128.js +119 -0
- package/dist/src/random/xorshift128.js.map +1 -0
- package/dist/src/random.d.ts +822 -0
- package/dist/src/random.d.ts.map +1 -0
- package/dist/src/random.js +992 -0
- package/dist/src/random.js.map +1 -0
- package/dist/src/test.d.ts +86 -0
- package/dist/src/test.d.ts.map +1 -0
- package/dist/src/test.js +160 -0
- package/dist/src/test.js.map +1 -0
- package/dist/src/time.d.ts +201 -0
- package/dist/src/time.d.ts.map +1 -0
- package/dist/src/time.js +300 -0
- package/dist/src/time.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { StringType, ArrayType } from "@elaraai/east";
|
|
6
|
+
import type { PlatformFunction } from "@elaraai/east/internal";
|
|
7
|
+
/**
|
|
8
|
+
* Joins path segments into a single path.
|
|
9
|
+
*
|
|
10
|
+
* Combines an array of path segments with a forward-slash (`/`) separator on every platform.
|
|
11
|
+
* Normalizes the resulting path by resolving `.` and `..` segments. Empty segments
|
|
12
|
+
* are ignored.
|
|
13
|
+
*
|
|
14
|
+
* This is a platform function for the East language, enabling path joining
|
|
15
|
+
* in East programs running in a browser.
|
|
16
|
+
*
|
|
17
|
+
* @param segments - Array of path segments to join (e.g., ["dir", "subdir", "file.txt"])
|
|
18
|
+
* @returns The joined path, using forward slashes (`/`) on every platform
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const buildPath = East.function([], StringType, $ => {
|
|
23
|
+
* const segments = $.let(["home", "user", "documents", "file.txt"], ArrayType(StringType));
|
|
24
|
+
* return Path.join(segments);
|
|
25
|
+
* // Returns: "home/user/documents/file.txt" on every platform
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const path_join: import("@elaraai/east").PlatformDefinition<[ArrayType<StringType>], StringType>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a path to an absolute path.
|
|
32
|
+
*
|
|
33
|
+
* Converts a relative path to an absolute path by resolving it against the current
|
|
34
|
+
* working directory. If the path is already absolute, it is normalized and returned.
|
|
35
|
+
* Resolves `.` and `..` segments to their actual locations.
|
|
36
|
+
*
|
|
37
|
+
* This is a platform function for the East language, enabling path resolution
|
|
38
|
+
* in East programs running in a browser. A browser has no working directory,
|
|
39
|
+
* so a relative path resolves against the root, `/`.
|
|
40
|
+
*
|
|
41
|
+
* @param path - The path to resolve (relative or absolute)
|
|
42
|
+
* @returns The absolute path
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const getAbsolutePath = East.function([], StringType, $ => {
|
|
47
|
+
* return Path.resolve("documents/../file.txt");
|
|
48
|
+
* // Returns: "/file.txt"
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const path_resolve: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the directory name from a path.
|
|
55
|
+
*
|
|
56
|
+
* Extracts the directory portion of a path by removing the last segment (file name).
|
|
57
|
+
* Similar to the Unix `dirname` command. Trailing path separators are ignored.
|
|
58
|
+
*
|
|
59
|
+
* This is a platform function for the East language, enabling directory extraction
|
|
60
|
+
* in East programs running in a browser.
|
|
61
|
+
*
|
|
62
|
+
* @param path - The file path to extract directory from
|
|
63
|
+
* @returns The directory portion of the path
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const getDir = East.function([], StringType, $ => {
|
|
68
|
+
* return Path.dirname("/home/user/documents/file.txt");
|
|
69
|
+
* // Returns: "/home/user/documents"
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare const path_dirname: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the base name (file name) from a path.
|
|
76
|
+
*
|
|
77
|
+
* Extracts the last segment of a path, typically the file name. Similar to the Unix
|
|
78
|
+
* `basename` command. Trailing path separators are ignored.
|
|
79
|
+
*
|
|
80
|
+
* This is a platform function for the East language, enabling filename extraction
|
|
81
|
+
* in East programs running in a browser.
|
|
82
|
+
*
|
|
83
|
+
* @param path - The file path to extract filename from
|
|
84
|
+
* @returns The file name portion of the path (including extension)
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const getFilename = East.function([], StringType, $ => {
|
|
89
|
+
* return Path.basename("/home/user/documents/file.txt");
|
|
90
|
+
* // Returns: "file.txt"
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare const path_basename: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the file extension from a path.
|
|
97
|
+
*
|
|
98
|
+
* Extracts the file extension from a path, including the leading dot. If the path
|
|
99
|
+
* has no extension or ends with a dot, returns an empty string. Only returns the
|
|
100
|
+
* last extension if multiple dots are present.
|
|
101
|
+
*
|
|
102
|
+
* This is a platform function for the East language, enabling extension extraction
|
|
103
|
+
* in East programs running in a browser.
|
|
104
|
+
*
|
|
105
|
+
* @param path - The file path to extract extension from
|
|
106
|
+
* @returns The file extension including the dot (e.g., ".txt"), or empty string if none
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const getExtension = East.function([], StringType, $ => {
|
|
111
|
+
* return Path.extname("/home/user/documents/file.txt");
|
|
112
|
+
* // Returns: ".txt"
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const path_extname: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
117
|
+
/**
|
|
118
|
+
* Browser implementation of path platform functions.
|
|
119
|
+
*
|
|
120
|
+
* Pass this array to {@link East.compile} to enable path operations.
|
|
121
|
+
*/
|
|
122
|
+
declare const PathImpl: PlatformFunction[];
|
|
123
|
+
/**
|
|
124
|
+
* Grouped path manipulation platform functions.
|
|
125
|
+
*
|
|
126
|
+
* Provides path utilities for East programs.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { East, StringType, ArrayType } from "@elaraai/east";
|
|
131
|
+
* import { Path } from "@elaraai/east-web-std";
|
|
132
|
+
*
|
|
133
|
+
* const buildPath = East.function([], StringType, $ => {
|
|
134
|
+
* const segments = $.let(["dir", "subdir", "file.txt"], ArrayType(StringType));
|
|
135
|
+
* const fullPath = $.let(Path.join(segments));
|
|
136
|
+
* const ext = $.let(Path.extname(fullPath));
|
|
137
|
+
* return fullPath;
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* const compiled = East.compile(buildPath, Path.Implementation);
|
|
141
|
+
* compiled(); // Returns: "dir/subdir/file.txt"
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare const Path: {
|
|
145
|
+
/**
|
|
146
|
+
* Joins path segments into a single path.
|
|
147
|
+
*
|
|
148
|
+
* Combines an array of path segments with a forward-slash (`/`) separator on every platform.
|
|
149
|
+
* Normalizes the resulting path and ignores empty segments.
|
|
150
|
+
*
|
|
151
|
+
* @param segments - Array of path segments to join
|
|
152
|
+
* @returns The joined path, using forward slashes (`/`) on every platform
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* const buildPath = East.function([], StringType, $ => {
|
|
157
|
+
* const segments = $.let(["home", "user", "file.txt"], ArrayType(StringType));
|
|
158
|
+
* return Path.join(segments);
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
readonly join: import("@elaraai/east").PlatformDefinition<[ArrayType<StringType>], StringType>;
|
|
163
|
+
/**
|
|
164
|
+
* Resolves a path to an absolute path.
|
|
165
|
+
*
|
|
166
|
+
* Converts a relative path to an absolute path by resolving it against the
|
|
167
|
+
* working directory, which in a browser is the root, `/`. Normalizes the
|
|
168
|
+
* path and resolves `.` and `..` segments.
|
|
169
|
+
*
|
|
170
|
+
* @param path - The path to resolve (relative or absolute)
|
|
171
|
+
* @returns The absolute path
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const getAbsolutePath = East.function([], StringType, $ => {
|
|
176
|
+
* return Path.resolve("documents/../file.txt"); // "/file.txt"
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
readonly resolve: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the directory name from a path.
|
|
183
|
+
*
|
|
184
|
+
* Extracts the directory portion of a path by removing the last segment (file name).
|
|
185
|
+
* Trailing path separators are ignored.
|
|
186
|
+
*
|
|
187
|
+
* @param path - The file path to extract directory from
|
|
188
|
+
* @returns The directory portion of the path
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const getDir = East.function([], StringType, $ => {
|
|
193
|
+
* return Path.dirname("/home/user/documents/file.txt");
|
|
194
|
+
* });
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
readonly dirname: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
198
|
+
/**
|
|
199
|
+
* Gets the base name (file name) from a path.
|
|
200
|
+
*
|
|
201
|
+
* Extracts the last segment of a path, typically the file name.
|
|
202
|
+
* Trailing path separators are ignored.
|
|
203
|
+
*
|
|
204
|
+
* @param path - The file path to extract filename from
|
|
205
|
+
* @returns The file name portion of the path (including extension)
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const getFilename = East.function([], StringType, $ => {
|
|
210
|
+
* return Path.basename("/home/user/documents/file.txt");
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
readonly basename: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
215
|
+
/**
|
|
216
|
+
* Gets the file extension from a path.
|
|
217
|
+
*
|
|
218
|
+
* Extracts the file extension from a path, including the leading dot.
|
|
219
|
+
* Returns empty string if no extension exists.
|
|
220
|
+
*
|
|
221
|
+
* @param path - The file path to extract extension from
|
|
222
|
+
* @returns The file extension including the dot (e.g., ".txt"), or empty string
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const getExtension = East.function([], StringType, $ => {
|
|
227
|
+
* return Path.extname("file.txt");
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* const compiled = East.compile(getExtension, Path.Implementation);
|
|
231
|
+
* compiled(); // Returns: ".txt"
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
readonly extname: import("@elaraai/east").PlatformDefinition<[StringType], StringType>;
|
|
235
|
+
/**
|
|
236
|
+
* Browser implementation of path platform functions.
|
|
237
|
+
*
|
|
238
|
+
* Pass this to {@link East.compile} to enable path operations.
|
|
239
|
+
*/
|
|
240
|
+
readonly Implementation: PlatformFunction[];
|
|
241
|
+
};
|
|
242
|
+
export { PathImpl };
|
|
243
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkR/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,iFAAkE,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,sEAA0D,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,sEAA0D,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,sEAA2D,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,sEAA0D,CAAC;AAEpF;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAAE,gBAAgB,EAmD/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI;IACb;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;OAeG;;IAGH;;;;;;;;;;;;;;;OAeG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;OAIG;;CAEG,CAAC;AAGX,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|