Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect cycles during development #119

Merged
merged 5 commits into from
Apr 15, 2016
Merged

Conversation

shamrin
Copy link
Contributor

@shamrin shamrin commented Apr 6, 2016

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

Related issues: #73 and #16.

if (process.env.NODE_ENV !== "production") {
if (level === undefined) {
level = 0;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level = level || 0;

@rtfeldman
Copy link
Owner

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 shamrin force-pushed the detect-cycles branch 3 times, most recently from 1acb501 to 660ac2d Compare April 14, 2016 22:16
@shamrin
Copy link
Contributor Author

shamrin commented Apr 14, 2016

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
Copy link
Owner

Beautiful! 😻 Thanks so much @shamrin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants