jhuckaby / megahash

A super-fast C++ hash table with Node.js wrapper, tested up to 1 billion keys.
Other
411 stars 29 forks source link

Add length as a property instead a method #8

Open mgesmundo opened 4 years ago

mgesmundo commented 4 years ago

This small PR add length as a property instead a method, like the ES6 Map. Thank you for your useful module! All the best

jhuckaby commented 3 years ago

Thank you very much for this PR. It's a very clever trick. You'll have to forgive me, but since this module is already in active use in so many places (including many of my own projects) I really don't want to introduce a "breaking change" to the API like this. I have code that is "relying" on length() being a method, and changing it to a property would bust all that code.

You are absolutely correct here, and this is very much the way I SHOULD have designed it from the start. Your way matches the ES6 Map spec exactly, which I was trying to mostly emulate. I wish I knew about this nifty trick at the time.

I might revisit this for a future v2.0 rewrite, when I can freely break the API, but for v1.x, I have to keep it locked down.

But seriously, thank you for the contribution!