utils icon indicating copy to clipboard operation
utils copied to clipboard

Handle Set serialization

Open RomainLanz opened this issue 3 years ago • 3 comments

Hey there! 👋🏻

This PR adds a specific case to serialize a Set to a stringable object.

RomainLanz avatar Sep 15 '22 15:09 RomainLanz

A couple of things.

  • If serialization support a data type, then it should be serialized in a consistent manner, regardless of the depth of the data type. That is how other data types are handled too
  • The more important one, is to carefully see if there is a common pattern for serializing Set and Map. Because, we are taking on to serialize a language specific data type to JSON (which is not very common). So, we should follow the due diligence and make sure we are inventing our own way of serializing them

thetutlage avatar Sep 16 '22 08:09 thetutlage

I am not sure we should handle Map since they are pretty different and more complex. You can provide anything as a key, meaning a non-keyable object that cannot be adequately serialized.

I have added @targos test to ensure we can serialize nested sets too.

RomainLanz avatar Sep 18 '22 08:09 RomainLanz

I saw that the ESM rewrite of this package is now using safe-stable-stringify that does not support Set.

Should we close this PR then and expect people to serialize it themself?

RomainLanz avatar Nov 03 '22 17:11 RomainLanz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 02 '23 18:01 stale[bot]