Closed slashwhatever closed 7 years ago
@slashwhatever the result in your example is a javascript object, not a collection of any type. So you have to check the number of keys in the object with Object.keys(myImmutable).length
or use something like _.size
from lodash.
If you make an array immutable you can just use .length
on it or again _.size
from lodash.
Thanks for the input @crudh. The fact we have to do something different for objects vs arrays is kinda my point. ImmutableJS allows you to use the same method name regardless of the type you're working with.
@slashwhatever yes, but the reasoning of seamless is that the types should be plain javascript types, with as few modifications as possible. So _.size
is probably the best suggestion for this use case.
@crudh understood :)
Immutable.js has a simple size member that allows you to check the existence of data in a collection (Map or List)
How do we do the same in seamless-immutable?
So we should be able to do something similar to this;