How to check if object is Immutable?

后端 未结 6 807
有刺的猬
有刺的猬 2020-12-29 01:44

Immutable object can be an instance of:

  • Immutable.List
  • Immutable.Map
  • Immutable.OrderedMap
6条回答
  •  长情又很酷
    2020-12-29 02:16

    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)

提交回复
热议问题