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

Always use strict equality #1225

Merged
merged 2 commits into from
May 15, 2020
Merged

Always use strict equality #1225

merged 2 commits into from
May 15, 2020

Conversation

medanat
Copy link
Contributor

@medanat medanat commented Jul 25, 2018

No description provided.

@codecov
Copy link

codecov bot commented Jul 25, 2018

Codecov Report

Merging #1225 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1225   +/-   ##
=======================================
  Coverage   99.38%   99.38%           
=======================================
  Files           4        4           
  Lines         484      484           
  Branches      130      130           
=======================================
  Hits          481      481           
  Partials        3        3           
Impacted Files Coverage Δ
lib/application.js 98.29% <100.00%> (ø)
lib/context.js 100.00% <100.00%> (ø)
lib/request.js 100.00% <100.00%> (ø)
lib/response.js 99.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d52105...b411130. Read the comment docs.

@medanat
Copy link
Contributor Author

medanat commented Sep 26, 2018

I think the reason for all these === PRs is 2 fold:

  1. Consistency: Koa already uses === in several places and == in others, no distinction as to why one or the other is used
  2. Clear intentions: Given the type coercion behavior of ==, it's best to use === to signify that no type coercion was necessary in the comparison

There was a time when === was more performant, that is no longer the case, not to measurable significance at least. However it's one less thing to consider when maintaining the codebase.

Copy link
Member

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

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

@medanat, can you update this PR !!

@medanat
Copy link
Contributor Author

medanat commented Apr 17, 2020

@3imed-jaberi done

Copy link
Member

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

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

@medanat, please check this suggesstion !!

onFinish(this.res, destroy.bind(null, val));
ensureErrorHandler(val, err => this.ctx.onerror(err));

// overwriting
if (null != original && original != val) this.remove('Content-Length');
if (null != original && original !== val) this.remove('Content-Length');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (null != original && original !== val) this.remove('Content-Length');
if (null !== original && original !== val) this.remove('Content-Length');

Copy link
Contributor Author

@medanat medanat Apr 18, 2020

Choose a reason for hiding this comment

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

Given the nature of type coercion with nulls, I'm not sure this will be a safe move.

null == undefined -> true, null === undefined -> false

Copy link
Member

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 !!

@niftylettuce niftylettuce merged commit 143d8f7 into koajs:master May 15, 2020
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.

3 participants