Skip to content

Serialize Map using a list of pairs#37

Merged
merelinguist merged 3 commits intomainfrom
model-maps-using-collection-of-entry-pairs
Aug 5, 2020
Merged

Serialize Map using a list of pairs#37
merelinguist merged 3 commits intomainfrom
model-maps-using-collection-of-entry-pairs

Conversation

@Skn0tt
Copy link
Copy Markdown
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