3

I need to detect if an object is some kind of Immutable or not. How do I do this?

BonsaiOak
  • 27,741
  • 7
  • 30
  • 54
  • Lots of good info in this thread: http://stackoverflow.com/questions/31907470/how-to-check-if-object-is-immutable Note that `isIterable` returns false for the `Record` type. – VanDanic Jan 25 '17 at 08:23

2 Answers2

2

https://github.com/facebook/immutable-js/issues/450

Doesn't look like they've gotten around to making a cleaner API for this, but for now you can use Immutable.Iterable.isIterable() to check if something is an iterable immutable collection.

Matt Mokary
  • 717
  • 6
  • 13
2

You can use Iterable.isIterable

Immutable.Iterable.isIterable(Immutable.Map()); // true
Immutable.Iterable.isIterable({}); // false

http://facebook.github.io/immutable-js/docs/#/Iterable/isIterable

Red Mercury
  • 3,971
  • 1
  • 26
  • 32