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

feat: handles inspection of objects with circular references #47

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

pcorpet
Copy link
Contributor

@pcorpet pcorpet commented Jun 10, 2021

Fix #44

Comment on lines +10 to +14
options.seen = options.seen || []
if (options.seen.indexOf(object) >= 0) {
return '[Circular]'
}
options.seen.push(object)
Copy link
Member

Choose a reason for hiding this comment

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

This all looks good but maybe a Set is a better choice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that not all environment that loupe supported had a Set, so I used a simple array. Note that this is the implementation that was used in the chaijs/chai inspect function

@codecov
Copy link

codecov bot commented Jun 24, 2021

Codecov Report

Merging #47 (bdcc1af) into master (5db74c7) will increase coverage by 0.30%.
The diff coverage is 100.00%.

❗ Current head bdcc1af differs from pull request most recent head 26cc144. Consider uploading reports for the commit 26cc144 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
+ Coverage   73.54%   73.84%   +0.30%     
==========================================
  Files          19       19              
  Lines         601      608       +7     
==========================================
+ Hits          442      449       +7     
  Misses        159      159              
Impacted Files Coverage Δ
lib/object.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5db74c7...26cc144. Read the comment docs.

@keithamus keithamus merged commit 1664d70 into chaijs:master Jun 24, 2021
@pcorpet pcorpet deleted the circular branch June 24, 2021 21:02
@github-actions
Copy link

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Handle circular references
2 participants