multiformats / clj-multihash

Clojure implementation of the Multihash spec
The Unlicense
40 stars 15 forks source link

[cljs] Use type symbol when extending base type #10

Closed plexus closed 5 years ago

plexus commented 5 years ago

As per https://cljs.github.io/api/cljs.core/extend-type when extending js/String the special symbol 'string should be used. This still makes the protocol work with strings but without changing the js/String prototype.

This removes a compile-time warning.

plexus commented 5 years ago

There's a bit more info in this thread

https://groups.google.com/forum/#!msg/clojurescript/MKEZ9CBU77o/h7ejrbNFCgAJ

extending JS base types like js/String can trigger dramatic de-optimization in JS engines (dixit David Nolen), which is why extend-type handles these separately.