js-on-sx: getOwnPropertyDescriptor handles arrays + strings
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
This commit is contained in:
@@ -4042,10 +4042,36 @@
|
||||
js-object-get-own-property-descriptor
|
||||
(fn
|
||||
(o key)
|
||||
(if
|
||||
(and (dict? o) (contains? (keys o) (js-to-string key)))
|
||||
{:configurable true :enumerable true :value (get o (js-to-string key)) :writable true}
|
||||
:js-undefined)))
|
||||
(let
|
||||
((sk (js-to-string key)))
|
||||
(cond
|
||||
((and (dict? o) (contains? (keys o) sk))
|
||||
{:configurable true :enumerable true :value (get o sk) :writable true})
|
||||
((list? o)
|
||||
(cond
|
||||
((= sk "length")
|
||||
{:configurable false :enumerable false :value (len o) :writable true})
|
||||
((js-int-key? sk)
|
||||
(let
|
||||
((i (js-num-to-int (js-string-to-number sk))))
|
||||
(cond
|
||||
((and (>= i 0) (< i (len o)))
|
||||
{:configurable true :enumerable true :value (nth o i) :writable true})
|
||||
(else :js-undefined))))
|
||||
(else :js-undefined)))
|
||||
((and (= (type-of o) "string"))
|
||||
(cond
|
||||
((= sk "length")
|
||||
{:configurable false :enumerable false :value (len o) :writable false})
|
||||
((js-int-key? sk)
|
||||
(let
|
||||
((i (js-num-to-int (js-string-to-number sk))))
|
||||
(cond
|
||||
((and (>= i 0) (< i (len o)))
|
||||
{:configurable false :enumerable true :value (char-at o i) :writable false})
|
||||
(else :js-undefined))))
|
||||
(else :js-undefined)))
|
||||
(else :js-undefined)))))
|
||||
|
||||
(define
|
||||
js-object-get-own-property-descriptors
|
||||
|
||||
Reference in New Issue
Block a user