评论者为:kurtharriger
上面的内容也暗示了也许可以在nil上扩展IEncodeClojure?
a
不是nil
,但它的类型是...也许在nil上扩展协议应该会这样工作?
但这没有... maybe this is a bug in satisfies?
?
`
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
`