评论者:kurtharriger
以上还表明,也许可以扩展nil上的IEncodeClojure?
a
不是 nil
,但它的类型是...所以拓展nil上的协议可能应该这样工作?
但是它不行...这可能是在satisfies?
中的一个bug?
`
cljs.user=> (def a (.create js/Object nil))
'cljs.user/a
cljs.user=> (aset a "test" 1)
1
cljs.user=> (extend-protocol IEncodeClojure)
nil
(-js->clj (link: x opts))
(let (link: {:keys [keywordize-keys)} opts
keyfn (if keywordize-keys keyword str)]
(into {} (for (link: k (js-keys x))
(link: (keyfn k) (js->clj (unchecked-get x k)) opts))))))
nil
cljs.user=> (js->clj a)
object(link: Object)
cljs.user=> (js-keys IEncodeClojure)
js (link: "null")
cljs.user=> (satisfies? IEncodeClojure a)
false
cljs.user=> (type a)
nil
`