-
Notifications
You must be signed in to change notification settings - Fork 3
safeStringify & %c support #121
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
Conversation
Dobrunia
commented
Apr 3, 2025
•
edited
Loading
edited
- Added support for %c formatting (like in the browser console).
- Fixed a bug: fix: properly handle cyclic objects
src/addons/consoleCatcher.ts
Outdated
|
||
return { | ||
message: args | ||
.map((arg) => (typeof arg === 'string' ? arg : safeStringify(arg))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if arg is number, boolean?
src/addons/consoleCatcher.ts
Outdated
/** | ||
* Safely stringifies objects handling circular references | ||
*/ | ||
const safeStringify = (obj: unknown): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using safe-stringify
since it is almost the same, but covered by tests
All ESLint issues should be fixed |
src/addons/consoleCatcher.ts
Outdated
* | ||
* @param arg - Console arguments | ||
*/ | ||
const stringifyArg = (arg: unknown): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use named function instead of anonymous