js-on-sx: for-in walks proto chain with shadowing, stops at native prototypes
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s
This commit is contained in:
@@ -3844,6 +3844,42 @@
|
||||
(k)
|
||||
(or (= k "__js_order__") (= k "__proto__"))))
|
||||
|
||||
(define
|
||||
js-for-in-keys
|
||||
(fn
|
||||
(o)
|
||||
(let
|
||||
((result (list)))
|
||||
(begin (js-for-in-walk o result) result))))
|
||||
|
||||
(define
|
||||
js-for-in-walk
|
||||
(fn
|
||||
(o acc)
|
||||
(cond
|
||||
((not (dict? o)) nil)
|
||||
((= o (get Object "prototype")) nil)
|
||||
((= o (get Array "prototype")) nil)
|
||||
((= o (get Number "prototype")) nil)
|
||||
((= o (get String "prototype")) nil)
|
||||
((= o (get Boolean "prototype")) nil)
|
||||
((= o (get Date "prototype")) nil)
|
||||
((= o (get RegExp "prototype")) nil)
|
||||
((= o (get Map "prototype")) nil)
|
||||
((= o (get Set "prototype")) nil)
|
||||
((= o (get js-function-global "prototype")) nil)
|
||||
(else
|
||||
(let
|
||||
((own (js-object-keys o)))
|
||||
(begin
|
||||
(for-each
|
||||
(fn (k) (if (contains? acc k) nil (append! acc k)))
|
||||
own)
|
||||
(cond
|
||||
((contains? (keys o) "__proto__")
|
||||
(js-for-in-walk (get o "__proto__") acc))
|
||||
(else nil))))))))
|
||||
|
||||
(define
|
||||
js-object-keys
|
||||
(fn
|
||||
|
||||
@@ -948,7 +948,7 @@
|
||||
(if
|
||||
(= iter-kind "of")
|
||||
(list (js-sym "js-iterable-to-list") iter-sx)
|
||||
(list (js-sym "js-object-keys") iter-sx))))
|
||||
(list (js-sym "js-for-in-keys") iter-sx))))
|
||||
(list
|
||||
(js-sym "for-each")
|
||||
(list
|
||||
|
||||
Reference in New Issue
Block a user