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:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user