Search code examples
immutable.js

How to check if object is Immutable?


Immutable object can be an instance of:

  • Immutable.List
  • Immutable.Map
  • Immutable.OrderedMap
  • Immutable.Set
  • Immutable.OrderedSet
  • Immutable.Stack

Solution

  • There is an open ticket to improve the API which is on the roadmap for 4.0. Until this is implemented, I suggest you use Immutable.Iterable.isIterable() (docs).

    Using instanceof is not reliable (e. g. returns false when different modules use different copies of Immutable.js)