rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

Detect cycles during development #119

Closed shamrin closed 8 years ago

shamrin commented 8 years ago

This throws development-only error when an object is too deeply nested.

Related issues: #73 and #16.

rtfeldman commented 8 years ago

Lovely, thank you! 😻

Two minor suggestions:

  1. Could you refactor level to be stackRemaining and decrement instead of incrementing? (Default to 64 instead of 0, and error when you reach 0.) That way if someone genuinely does have something that needs 65 stack frames, they can opt into upping the limit with an intuitive API.
  2. Could you add something to the README documenting this?

Thanks so much for this!

shamrin commented 8 years ago

Done!

I've also written about this problem in wiki. Error message now links to it: https://github.com/rtfeldman/seamless-immutable/wiki/Deeply-nested-object-was-detected

rtfeldman commented 8 years ago

Beautiful! 😻 Thanks so much @shamrin!