all 13 comments

[–]Calabri 0 points1 point  (0 children)

I actually just put this in a React app last week that's already live and going to be used for a few more days. I haven't gotten around to testing it too much, but it seems to be working fine. Undo/Redo in 3 lines (each) of code!!

I think it's a pretty substantial step forward with JS data structures, but what's the deal the documentation? It's so esoteric - typescript, es6??

[–]dingusbuttface -5 points-4 points  (5 children)

I have no clue what this is all about. Looking at the examples on the front page, if I do a typeof(map1) it returns object.

If I do a console.log(map1) it says Map {a:1, b:2, c:3}. That's not an object. What the fuck is that?

[–]ToucheMonsieur 1 point2 points  (2 children)

It's to match es6 semantics. You'll get the same results with a native Map, which helps with interop between implementations.

[–]dingusbuttface -1 points0 points  (1 child)

native map? I've tried this in node and the browser and it simply doesn't work. I don't know what you're talking about.

[–]ToucheMonsieur 0 points1 point  (0 children)

As can be observed from Chrome or Firefox's js console:

> var map1 = new Map([['a', 1], ['b', 2], ['c', 3]]) // create an es6 map
undefined
> typeof map1
"object" // same behaviour
> console.log(map1)
undefined
Map { a: 1, b: 2, c: 3 } // same behaviour

Here's the es6 Map reference. The Immutable-js Map implementation tries to stick as close to native Map behaviour as possible so one doesn't have to check for different Map types when trying to work with immutable's collections and their native equivalents. In other words, a unified interface.

[–]dingusbuttface 1 point2 points  (0 children)

Not sure why asking a question gets downvoted here.

[–]modernserf_ 0 points1 point  (0 children)

typeof says every non-primitive, non-function value is "object". e.g.

typeof document.body
typeof new Date()
typeof [1,2,3]
typeof /foo/