Node JS, traditional data structures? (such as Set, etc), anything like Java.util for node? [closed]
I’m loving node JS and, coming from a Java background, am interested in even trying it out for some projects where node may seem a bit of a stretch, such as a search engine project.
I apologize if there are other questions like this, however I spent some time searching and didn’t come up with much.
es6 has a Set class built in:
underscore that should make it easier to build the type of structures that you want.
Its no longer true that node.js doesn’t have
Map objects among other things. node.js has had them since at latest v12.
But of course, if you want libraries like java has, check npm or github. You’re not limited to what comes standard in node.js.
Have you looked into Underscore.js? http://underscorejs.org/
It’s not a one to one with java.util but it provides a bunch of commonly needed utility functions.
As a lighter and faster alternative to Underscore.js, Lo-Dash (http://lodash.com/) is getting traction those days… But this is not Java.util! 🙂
Have a look at this one: https://github.com/chenglou/data-structures
I think it fits what you are looking for.
This library has strict time complexity guarantee and can be used with confidence.
The latest beta version includes iterator functions which can be used like iterator in c++.
Included data structures
- Set (using RBTree)
- Map (using RBTree)
- HashSet (for reference only)
- HashMap (for reference only)
To help you have a better use, we provide this API document.