Skip to content

Fixes #25 Add support for stringifying event data with a maxDepth #127

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

Merged
merged 23 commits into from
Mar 17, 2023

Conversation

niemyjski
Copy link
Member

@niemyjski niemyjski commented Mar 1, 2023

We added the most robust stringify and prune implementation out there. At minimum it's 12x all other implementations.

@niemyjski niemyjski self-assigned this Mar 1, 2023
@niemyjski niemyjski marked this pull request as ready for review March 17, 2023 02:27
@niemyjski niemyjski force-pushed the feature/json_stringify_depth branch from aaf2b06 to a65e7a7 Compare March 17, 2023 02:27
@niemyjski niemyjski requested a review from ejsmith March 17, 2023 02:28
Copy link
Member Author

@niemyjski niemyjski left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Member

@ejsmith ejsmith left a comment

Choose a reason for hiding this comment

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

Seems good.

Comment on lines +218 to +240
switch (typeof value) {
case "function":
return true;
case "object":
switch (Object.prototype.toString.call(value)) {
case "[object AsyncGenerator]":
case "[object Generator]":
case "[object ArrayBuffer]":
case "[object Buffer]":
case "[object DataView]":
case "[object Promise]":
case "[object WeakMap]":
case "[object WeakSet]":
return true;
}

// Check for buffer;
if ("writeBigInt64LE" in value) {
return true;
}

break;
}
Copy link
Member

Choose a reason for hiding this comment

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

Sure seems like we'd be better off having a list of things that we allow vs trying to keep an exhaustive list of unsupported types when new types can be added and probably different runtimes have different built in types as well. There are only so many intrinsic types that we should support.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we can work towards improving this. I'm assuming there will be more types over time, and we will need to optimize this some.

@niemyjski niemyjski merged commit c0d6665 into main Mar 17, 2023
@niemyjski niemyjski deleted the feature/json_stringify_depth branch March 17, 2023 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants