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

assert: fix loose set and map comparison #22495

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,10 @@ function findLooseMatchingPrimitives(prim) {
case 'symbol':
return false;
case 'string':
const number = +prim;
prim = +prim;
Copy link
Member

Choose a reason for hiding this comment

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

Not a huge fan of this change (makes it harder to follow IMO) but still LGTM on the PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shall I change it back?

Copy link
Member

Choose a reason for hiding this comment

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

No strong feelings - I'm just not a fan of this sort of assignment since it takes another extra step to follow - but you can absolutely land as is if you want.

// Loose equal entries exist only if the string is possible to convert to
// a regular number and not NaN.
if (Number.isNaN(number)) {
return false;
}
// Fall through
case 'number':
if (Number.isNaN(prim)) {
return false;
Copy link
Member

@jdalton jdalton Aug 27, 2018

Choose a reason for hiding this comment

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

☝️ might pluck the Number.isNaN reference above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment addressed.

Expand Down