Skip to content

Handle NaN#75

Merged
mcollina merged 2 commits into
mcollina:masterfrom
valichek:fix-nan
Sep 17, 2018
Merged

Handle NaN#75
mcollina merged 2 commits into
mcollina:masterfrom
valichek:fix-nan

Conversation

@valichek

@valichek valichek commented Sep 17, 2018

Copy link
Copy Markdown
Contributor

Fixes: #74.

Comment thread test/15-elements-maps.js Outdated
var toEncode = { a: NaN, hello: 'world' }
var buf = instance.encode(toEncode)

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

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

@mcollina mcollina left a comment

Copy link
Copy Markdown
Owner

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.

2 participants