intelie / immutable-js-diff

MIT License
260 stars 32 forks source link

Cannot perform diff on a Map with non string keys #13

Open kbrownlees opened 7 years ago

kbrownlees commented 7 years ago
> a = i.Map().set(null, 1)
> b = i.Map().set(null, 2)
> id(a, b)
param str (null) is not a string

The error comes from https://github.com/intelie/immutable-js-diff/blob/master/src/path.js#L14 where it is trying to determine the path of the key (https://github.com/intelie/immutable-js-diff/blob/master/src/diff.js#L56).

tiye commented 7 years ago

Somehow it appears to me that we should avoid using null as a key...

pedroteixeira commented 7 years ago

You're probably right. This type of key doesn't seem to be supported, mainly because the implementation was based on the JSON Patch https://tools.ietf.org/html/rfc6902, where all object keys are string.

Not sure what's the best way to go in representing non-string keys for the patch. Perhaps a escaped symbol to represent?

Feel free to submit Pull Requests or ideas!