Skip to content

Won't trycatch different types - #15

Merged
ljharb merged 1 commit into
inspect-js:masterfrom
KoryNunn:master
Aug 3, 2019
Merged

Won't trycatch different types#15
ljharb merged 1 commit into
inspect-js:masterfrom
KoryNunn:master

Conversation

@KoryNunn

Copy link
Copy Markdown
Contributor

The current version will hit the trycatch in objEquiv if you compare, for example, false to []

This should significantly improve the performance of checks between values of different types.

Tests pass, however I'm not totally confident that there are enough tests to catch potential edge cases.

@KoryNunn

Copy link
Copy Markdown
Contributor Author

The failed build looks unrelated to the pull.

@ljharb

This comment has been minimized.

@ljharb ljharb added the needs "allow edits" Please check "allow edits" in the right hand side of the PR. label Jul 31, 2019
@KoryNunn

This comment has been minimized.

@ljharb ljharb removed the needs "allow edits" Please check "allow edits" in the right hand side of the PR. label Aug 1, 2019
@ljharb

ljharb commented Aug 1, 2019

Copy link
Copy Markdown
Member

hmm - how does this affect comparing a function to an object? that's the one case I'd be worried about.

@ljharb

ljharb commented Aug 3, 2019

Copy link
Copy Markdown
Member

nvm, looked at https://github.com/nodejs/node/blob/master/lib/internal/util/comparisons.js and added some tests to this PR.

@ljharb
ljharb merged commit 410e2d6 into inspect-js:master Aug 3, 2019
ljharb added a commit that referenced this pull request Aug 28, 2019
This technically could have been a patch, but I'm making it a minor out
of an abundance of caution.

 - [Fix] use `is-date-object` to properly detect cross-realm Dates
 - [Fix] ensure Buffer + non-Buffer comparison order does not matter
 - [Fix] properly compare RegExp objects
 - [Fix] use `object-is` to support `NaN` and `-0` properly (#57, #20)
 - [Fix] (array,arguments) now behaves the same as (arguments,array) (#56)
 - [Refactor] there is no need to do further comparing when two types are not equal (#44)
 - [Refactor] `objEquiv`: bail early if typeofs are different (#15)
 - [Refactor] Use `object-keys` and `is-arguments` instead of a homegrown shim (#4)
 - [Refactor] move Date and RegExp tests into `objEquiv`
 - [Dev Deps] update `tape`
 - [Tests] make a `tape` helper, to easily compare loose/strict, and (a,b)/(b,a) arg order
 - [Tests] add array/object tests; clean up/flesh out tests
 - [Tests] add tests for `Object.create(null)` (#50)
 - [Tests] Fails simple array tests on IE < 9 #10 (#64)
 - [Tests] add `npm run lint`
 - [Tests] up to `node` `v12.7`, `v11.15`, `v10.16`, `v9.11`, `v8.16`, `v7.10`, `v6.17`, `4.9`; use `nvm install-latest-npm`
 - [meta] fix license text so GitHub can detect it
 - [meta] Add copyright statements (#59, #14)
 - [meta] Only apps should have lockfiles
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