js-on-sx: Object.keys throws on null/undefined, walks indices on string/array
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
This commit is contained in:
@@ -3982,6 +3982,18 @@
|
||||
(fn
|
||||
(o)
|
||||
(cond
|
||||
((or (= o nil) (js-undefined? o))
|
||||
(raise (js-new-call TypeError (js-args "Object.keys called on null or undefined"))))
|
||||
((= (type-of o) "string")
|
||||
(let ((result (list)) (n (len o)))
|
||||
(begin
|
||||
(js-string-keys-loop result 0 n)
|
||||
result)))
|
||||
((list? o)
|
||||
(let ((result (list)) (n (len o)))
|
||||
(begin
|
||||
(js-string-keys-loop result 0 n)
|
||||
result)))
|
||||
((dict? o)
|
||||
(cond
|
||||
((contains? (keys o) "__js_order__")
|
||||
@@ -4002,6 +4014,17 @@
|
||||
result)))))
|
||||
(else (list)))))
|
||||
|
||||
(define
|
||||
js-string-keys-loop
|
||||
(fn
|
||||
(acc i n)
|
||||
(cond
|
||||
((>= i n) nil)
|
||||
(else
|
||||
(begin
|
||||
(append! acc (js-to-string i))
|
||||
(js-string-keys-loop acc (+ i 1) n))))))
|
||||
|
||||
(define
|
||||
js-object-values
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user