Skip to content

Add toJSON#26

Merged
yassernasc merged 4 commits intomainfrom
toJSON
Feb 27, 2026
Merged

Add toJSON#26
yassernasc merged 4 commits intomainfrom
toJSON

Conversation

@yassernasc
Copy link
Contributor

No description provided.

@yassernasc yassernasc requested a review from a team February 26, 2026 18:51
Copy link
Contributor

@kasperisager kasperisager left a comment

Choose a reason for hiding this comment

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

This is one of the Node.js features I'd rather leave at "toJSON is not a function". It was from its v0 days.

@yassernasc
Copy link
Contributor Author

No problem, we can close the PR then and reopen it when needed if that day comes.

@kasperisager
Copy link
Contributor

What I'd actually much rather we do if we were to add buffer.toJSON() is have it return a plain array. That's not only more general but also intentionally breaks compatibility with other Node.js-likes in a way that forces consumers to either a) use a structured schema or b) use the replacer and reviver arguments of the JSON methods. Both options are better and supported in all JavaScript environments regardless of the presence or absence of buffer.toJSON().

@yassernasc yassernasc merged commit 6cb7d81 into main Feb 27, 2026
3 checks passed
@yassernasc yassernasc deleted the toJSON branch February 27, 2026 10:55
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.

2 participants