Initial ES modules support

This commit is contained in:
2026-10-26 12:39:58 +00:00
parent f7c5b2c80f
commit 1e12e7be2e
35 changed files with 1266 additions and 505 deletions
+10 -2
View File
@@ -1,5 +1,13 @@
import {
__rt_number_to_string,
__rt_string_char_code_at,
__rt_string_concat,
__rt_string_from_char_code,
__rt_string_slice,
} from "jsrt:native";
// Converts any value to a string, like the spec's ToString
function String(x) {
export function String(x) {
switch (typeof x) {
case "string": return x;
case "number": return __rt_number_to_string(x);
@@ -109,7 +117,7 @@ function clampIndex(i, len) {
}
// An index where a negative value counts from the end, clamped to [0, len]
function relativeIndex(i, len) {
export function relativeIndex(i, len) {
return clampIndex(i < 0 ? i + len : i, len);
}