Yomguithereal / mnemonist

Curated collection of data structures for the JavaScript/TypeScript language.
https://yomguithereal.github.io/mnemonist
MIT License
2.24k stars 92 forks source link

Support toStringTag #129

Open xamgore opened 4 years ago

xamgore commented 4 years ago

According to the latest spec and typescript definitions, standard Map interface implements Symbol.toStringTag property.

(new Map())[Symbol.toStringTag]
> "Map"

Maybe DefaultMap and other data structures in mnemonist should do the same?

Yomguithereal commented 4 years ago

Sure @xamgore. Why not? Could be a useful addition for some use cases. This could be done in a similar fashion than nodejs custom inspection symbol here to ensure that it does not break usage with older runtimes. You need to check that Symbol do exist and that this particular symbol also exists before setting it to the required prototypes. Do you want to open a PR to add this to structures that are useful to you?