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

Handle NaN #75

Merged
merged 2 commits into from Sep 17, 2018
Merged

Handle NaN #75

merged 2 commits into from Sep 17, 2018

Conversation

valichek
Copy link
Contributor

@valichek valichek commented Sep 17, 2018

Fixes: #74.

var toEncode = { a: NaN, hello: 'world' }
var buf = instance.encode(toEncode)

t.deepEqual(expected, instance.decode(buf), 'must ignore NaN')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? Shouldn't it have the same behavior as encoded directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it same as for undefined value

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are different. The behavior of undefined  is matching how JSON.stringify() works. undefined  in javascript means "there is nothing here". NaN  has a different meaning altogether. It should throw anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will remove that

Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit 2b96cd2 into mcollina:master Sep 17, 2018
This was referenced Mar 12, 2021
This was referenced Mar 12, 2021
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.

None yet

2 participants