js-on-sx: js-add ToPrimitive's Date and plain Objects via valueOf/toString
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s

This commit is contained in:
2026-05-09 05:56:01 +00:00
parent 76d6528c51
commit 013ce15357
2 changed files with 26 additions and 1 deletions

View File

@@ -1969,7 +1969,30 @@
(get v "__js_number_value__"))
((contains? (keys v) "__js_boolean_value__")
(get v "__js_boolean_value__"))
(else v))))
((contains? (keys v) "__js_is_date__")
(js-add-call-method v "toString"))
(else (js-add-toprim-default v)))))
(define
js-add-toprim-default
(fn
(v)
(let
((via-valueof (js-add-call-method v "valueOf")))
(cond
((not (= (type-of via-valueof) "dict")) via-valueof)
(else (js-add-call-method v "toString"))))))
(define
js-add-call-method
(fn
(v name)
(let
((m (js-dict-get-walk v name)))
(cond
((js-undefined? m) v)
((not (js-function? m)) v)
(else (js-call-with-this v m (list)))))))
(define
js-add