GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: reduce util.is*() usage by cjihrig · Pull Request #647 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.), which are infrequently used anyway.

Closes #607

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brendanashworth

brendanashworth commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

This will conflict with the changes in #601 and #605, by the way.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jan 29, 2015

Copy link
Copy Markdown
Contributor

I think we should document which conventions we will be using first.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jan 31, 2015

Copy link
Copy Markdown
Contributor Author

Are docs the only thing holding this up? I think @chrisdickinson was going to write something up.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisdickinson

chrisdickinson commented Jan 31, 2015

Copy link
Copy Markdown
Contributor

I'll have a PR this coming week. I would not consider that a blocker for landing this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Jan 31, 2015
View reviewed changes
Comment thread lib/_http_client.js

@bnoordhuis bnoordhuis Jan 31, 2015

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can be shortened to agent == null.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Jan 31, 2015

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

OK. I'll update these. I was trying to avoid using ==.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Jan 31, 2015

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

On second thought, I'll leave it to your good judgment. Doing the explicit checks is a little more efficient than == because they don't generate an IC.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented Jan 31, 2015

Copy link
Copy Markdown
Member

Do people have opinions on what is better, Array.isArray(x) or x instanceof Array? I ask because of the following:

> var x = []; x.__proto__ = {};
{}
> Array.isArray(x)
true
> x instanceof Array
false

With Array.isArray(), you don't know if Array prototype methods are available on the instance.

Second question: should String objects be considered strings? Right now, only primitive strings are accepted. new String('foo') is either rejected or (in the binding layer) asserts.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg

rvagg commented Jan 31, 2015

Copy link
Copy Markdown
Member

@chrisdickinson will your style-guide cover the specifics of when to use what type of type checking? There was a suggestion in the TC meeting to bring @micnic in to help with that effort since he raised the concern originally in #607. So, if it's not straight-forward and you'd like input, then you could try and rope him in and use this PR as a basis for coming up with that specific list of rules for a style-guide.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin

vkurchatkin commented Jan 31, 2015

Copy link
Copy Markdown
Contributor

@bnoordhuis there is an opposite example: vm.runInNewContext('[]') instanceof Array. Returns false, though it actually IS an array and has all prototype methods available.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jan 31, 2015

Copy link
Copy Markdown
Contributor Author

FWIW, the current util.isArray() is just an alias to Array.isArray().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
lib: reduce util.is*() usage
b4ccdec
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).
@cjihrig

cjihrig commented Jan 31, 2015

Copy link
Copy Markdown
Contributor Author

@bnoordhuis I've updated the isObject() checks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Jan 31, 2015
View reviewed changes
Comment thread lib/child_process.js

@bnoordhuis bnoordhuis Jan 31, 2015

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The parens are superfluous here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented Jan 31, 2015

Copy link
Copy Markdown
Member

LGTM sans a tiny style nit. Land at will if https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/142/ is happy.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig added a commit that referenced this pull request Feb 1, 2015
@cjihrig
lib: reduce util.is*() usage
6ac8bdc
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: #607
PR-URL: #647
Reviewed-By: Ben Noordhuis <[email protected]>
@cjihrig

cjihrig commented Feb 1, 2015

Copy link
Copy Markdown
Contributor Author

Landed in 6ac8bdc

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig closed this Feb 1, 2015
@cjihrig
cjihrig deleted the util-is branch February 1, 2015 04:54
brendanashworth added a commit to brendanashworth/io.js that referenced this pull request Mar 14, 2015
@brendanashworth
http: rebase and update 8ff6b81
b3b6b24
This commit does various changes to cleanup and prep the 8ff6b81 for
merging, which include updating the commit to follow new codebase
guidelines. The following are the changes:

doc/api/http.markdown:
  - document options
lib/http.js:
  - no changes
lib/_http_server.js
  - changes regarding isObject (nodejs#647) and hasOwnProperty (nodejs#635)
  - take tls option rather than guessing based on options
test/simple/test-https-from-http.js:
  - moved to parallel directory, crypto test, removed copyright banner
test/parallel/test-http-server.js:
  - adjust for tls option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@cjihrig @brendanashworth @Fishrock123 @chrisdickinson @bnoordhuis @rvagg @vkurchatkin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.