js-on-sx: String.fromCharCode + parseInt + parseFloat

String global with fromCharCode (variadic). parseInt truncates via
js-math-trunc; parseFloat delegates to js-to-number. Wired into
js-global.

381/383 unit (+5), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 21:16:41 +00:00
parent 449b77cbb0
commit 6f0b4fb476
3 changed files with 51 additions and 1 deletions

View File

@@ -1608,6 +1608,34 @@
(define Array {:isArray js-array-is-array :of js-array-of})
(define
js-string-from-char-code
(fn (&rest args) (js-string-from-char-code-loop args 0 "")))
(define
js-string-from-char-code-loop
(fn
(args i acc)
(if
(>= i (len args))
acc
(js-string-from-char-code-loop
args
(+ i 1)
(str acc (js-code-to-char (js-num-to-int (nth args i))))))))
(define String {:fromCharCode js-string-from-char-code})
(define
parseInt
(fn
(&rest args)
(if (= (len args) 0) 0 (js-math-trunc (js-to-number (nth args 0))))))
(define
parseFloat
(fn (&rest args) (if (= (len args) 0) 0 (js-to-number (nth args 0)))))
(define
js-promise-flush-callbacks!
(fn
@@ -2022,4 +2050,4 @@
(str "/" (get rx "source") "/" (get rx "flags")))
(else js-undefined))))
(define js-global {:isFinite js-global-is-finite :console console :Number Number :Math Math :Array Array :NaN 0 :Infinity inf :isNaN js-global-is-nan :Object Object :undefined js-undefined})
(define js-global {:isFinite js-global-is-finite :console console :Number Number :Math Math :Array Array :String String :NaN 0 :Infinity inf :isNaN js-global-is-nan :Object Object :undefined js-undefined})