-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Change default value of ipc
to advanced
#784
Comments
@sindresorhus Based on the above, do you think the default value of the In a nutshell:
|
|
ehmicky
changed the title
Small insights about
Change default value of Mar 11, 2024
ipc
serialization formatsipc
to advanced
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have done some small research on the difference between the
json
and theadvanced
serialization formats of theipc
feature. I just wanted to share them for future reference, so will close this issue.Speed
Generally speaking,
json
is ~1.3x faster on small values, whileadvanced
is up to 6x faster faster on big values. This aligns with what the Node.js PR that introduced this feature is benchmarking too. Which is a bit more nuanced than what the documentation is mentioning.Using my machine (Node 21, Ubuntu 23.10),
advanced
is:Benchmark code:
Compatibility
The documentation mentions that:
I have tried many values of different types. The result is this:
advanced
keeps regExps,Map
,Set
,ArrayBuffer
,ArrayBufferView
,Buffer
andUint8Array
as is. Those values are serialized to empty objects withjson
advanced
keepsDate
instances as is. Those are serialized to strings withjson
.advanced
supportsundefined
and bigint, except at the top-level. Those values throw withjson
.advanced
keepsundefined
object properties as is. Those properties are filtered out withjson
.advanced
supportsNaN
,Infinity
. Alsoundefined
array items. Those values are serialized tonull
withjson
.advanced
supports circular references. Those values throw withjson
.advanced
has a generic (not full) support forError
instances. Those values are serialized to empty objects withjson
.advanced
throws if an object/array contains functions or symbols. Those properties are filtered out (but do not error) withjson
.Intl.*
So I would personally consider
advanced
to be mostly a superset ofjson
, which the following caveats:advanced
, while they are ignored withjson
.toJSON()
throw, while they are handled byjson
I wanted to share this information for any future discussion around that feature.
The text was updated successfully, but these errors were encountered: