Skip to content Skip to sidebar Skip to footer

Node Js, Traditional Data Structures? (such As Set, Etc), Anything Like Java.util For Node?

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

Solution 1:

es6 has a Set class built in:

newSet([iterable]);

see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

Solution 2:

Collections.js has Lists, Maps, Queues, Sets, and Heaps, all with consistent interfaces. Github.

Solution 3:

it seems JavaScript is lacking traditional data structures...

Yes, this is javascript, the very concept and implementation of data structure is done quite differently from languages like Java.

I'm not sure that you're really going to find what you're looking for with Javascript. Howver, there are some libraries like underscore that should make it easier to build the type of structures that you want.

Solution 4:

Its no longer true that node.js doesn't have Set and 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.

Solution 5:

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.

Post a Comment for "Node Js, Traditional Data Structures? (such As Set, Etc), Anything Like Java.util For Node?"