Skip to content
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

Serialize Map using a list of pairs #37

Merged
merged 3 commits into from
Aug 5, 2020

Conversation

Skn0tt
Copy link
Collaborator

@Skn0tt Skn0tt commented Aug 1, 2020

Closes #33, #35

While we had been trying to fit Map's semantics into JSON's object, the solution had been in front of us all along: It's impossible!
That's why new Map(...) takes a list of pairs instead of an object.

This PR suggests to also use a list of pairs to serialize Map, which allows us to distinguish different objects from one another and also support non-primitive values.

This PR may be a bit hard to comprehend, so please go forward and ask all the questions you like ^^

While we had been trying to fit Map's semantics into JSON's object,
the solution had been in front of us all along: It's impossible!
`new Map()` takes a list of pairs and not an object, because objects are inherently
less powerful than Maps.
By also using list of pairs to describe `Map`, we finally can serialize
`Map<RegExp, V>` or `Map<{}, V>`.

See introduced tests in `index.test.ts` for reference! :D
@Skn0tt Skn0tt requested a review from merelinguist August 1, 2020 11:57
@Skn0tt Skn0tt changed the title Serialize maps using arrays of pairs Serialize Map using a list of pairs Aug 1, 2020
@Skn0tt Skn0tt mentioned this pull request Aug 3, 2020
@merelinguist merelinguist merged commit 8e4609a into main Aug 5, 2020
@merelinguist merelinguist deleted the model-maps-using-collection-of-entry-pairs branch August 5, 2020 14:06
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.

Add support for non-uniformly typed Maps
2 participants