{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/76598648","id":76598648,"diff_hunk":"@@ -1330,21 +1332,20 @@ Server.prototype.listen = function() {\n   var args = new Array(arguments.length);\n   for (var i = 0; i < arguments.length; i++)\n     args[i] = arguments[i];\n-  args = normalizeArgs(args);\n+  var [options, cb] = normalizeArgs(args);\n \n-  if (args[1]) {\n-    this.once('listening', args[1]);\n+  if (typeof cb === 'function') {\n+    this.once('listening', cb);\n   }\n \n-  var options = args[0];\n-  if (arguments.length === 0 || typeof arguments[0] === 'function') {\n+  if (args.length === 0 || typeof args[0] === 'function') {\n     // Bind to a random port.\n     options.port = 0;\n   }\n \n   // The third optional argument is the backlog size.\n   // When the ip is omitted it can be the second argument.\n-  var backlog = toNumber(arguments[1]) || toNumber(arguments[2]);\n+  var backlog = toNumber(args[1]) || toNumber(args[2]);","path":"lib/net.js","position":69,"original_position":34,"commit_id":"3848eaee4e40547a25e587b6c6bedcd2e888cd10","original_commit_id":"3fb143576e2705c8822c7bb8be253f01536862d4","user":{"login":"jscissr","id":4520820,"avatar_url":"https://avatars.githubusercontent.com/u/4520820?v=3","gravatar_id":"","url":"https://api.github.com/users/jscissr","html_url":"https://github.com/jscissr","followers_url":"https://api.github.com/users/jscissr/followers","following_url":"https://api.github.com/users/jscissr/following{/other_user}","gists_url":"https://api.github.com/users/jscissr/gists{/gist_id}","starred_url":"https://api.github.com/users/jscissr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jscissr/subscriptions","organizations_url":"https://api.github.com/users/jscissr/orgs","repos_url":"https://api.github.com/users/jscissr/repos","events_url":"https://api.github.com/users/jscissr/events{/privacy}","received_events_url":"https://api.github.com/users/jscissr/received_events","type":"User","site_admin":false},"body":"ping @mscdex ","created_at":"2016-08-29T12:32:16Z","updated_at":"2016-08-29T12:32:16Z","html_url":"https://github.com/nodejs/node/pull/4039#discussion_r76598648","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/4039","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/76598648"},"html":{"href":"https://github.com/nodejs/node/pull/4039#discussion_r76598648"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/4039"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/4039","id":51935201,"html_url":"https://github.com/nodejs/node/pull/4039","diff_url":"https://github.com/nodejs/node/pull/4039.diff","patch_url":"https://github.com/nodejs/node/pull/4039.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/4039","number":4039,"state":"open","locked":false,"title":"net: refactor Server.prototype.listen","user":{"login":"jscissr","id":4520820,"avatar_url":"https://avatars.githubusercontent.com/u/4520820?v=3","gravatar_id":"","url":"https://api.github.com/users/jscissr","html_url":"https://github.com/jscissr","followers_url":"https://api.github.com/users/jscissr/followers","following_url":"https://api.github.com/users/jscissr/following{/other_user}","gists_url":"https://api.github.com/users/jscissr/gists{/gist_id}","starred_url":"https://api.github.com/users/jscissr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jscissr/subscriptions","organizations_url":"https://api.github.com/users/jscissr/orgs","repos_url":"https://api.github.com/users/jscissr/repos","events_url":"https://api.github.com/users/jscissr/events{/privacy}","received_events_url":"https://api.github.com/users/jscissr/received_events","type":"User","site_admin":false},"body":"This PR simplifies `Server.prototype.listen`, removing some redundancy and inconsistency.\r\n\r\nBecause `listen` and `connect` have a similar function signature, `normalizeConnectArgs` can be reused for `listen`.\r\n\r\n`listenAfterLookup` renamed to `lookupAndListen` for consistency with `lookupAndConnect`, and moved out of `Server.prototype.listen`.\r\n\r\n## Functional differences\r\n\r\nTo improve consistency, I actually made some small functional changes:\r\n\r\n- `port` was checked with this complicated code if set in a config object:\r\n  ```\r\n  if (typeof h.port === 'number' || typeof h.port === 'string' ||\r\n      (typeof h.port === 'undefined' && 'port' in h)) {\r\n    // Undefined is interpreted as zero (random port) for consistency\r\n    // with net.connect().\r\n    if (typeof h.port !== 'undefined' && !isLegalPort(h.port))\r\n      throw new RangeError('\"port\" option should be >= 0 and < 65536: ' +\r\n                           h.port);\r\n    …\r\n  ```\r\n  But if set as first argument, it was only coerced to a number with `var port = toNumber(arguments[0]);`.\r\n  Now, it is consistently using the first way, `toNumber` is not used anymore.\r\n \r\n  However this is a breaking change, because before invalid ports resulted in using a random port instead of throwing.\r\n\r\n- `addressType` was sometimes `null` and sometimes `4`, if no address is given.\r\n  Now it is always `4`.\r\n\r\n- `host` was checked like this:\r\n  ```\r\n  if (arguments[1] !== undefined &&\r\n      typeof arguments[1] !== 'function' &&\r\n      typeof arguments[1] !== 'number')\r\n  ```\r\n  Now it is checked with `if (typeof arguments[1] === 'string')`, this is consistent with `connect`.","created_at":"2015-11-26T17:23:49Z","updated_at":"2016-08-29T12:32:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59062445144e7f8846ebe91574d7be0bd6be6dac","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/nodejs/node/milestones/15","html_url":"https://github.com/nodejs/node/milestones/7.0.0","labels_url":"https://api.github.com/repos/nodejs/node/milestones/15/labels","id":1582957,"number":15,"title":"7.0.0","description":"","creator":{"login":"targos","id":2352663,"avatar_url":"https://avatars.githubusercontent.com/u/2352663?v=3","gravatar_id":"","url":"https://api.github.com/users/targos","html_url":"https://github.com/targos","followers_url":"https://api.github.com/users/targos/followers","following_url":"https://api.github.com/users/targos/following{/other_user}","gists_url":"https://api.github.com/users/targos/gists{/gist_id}","starred_url":"https://api.github.com/users/targos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/targos/subscriptions","organizations_url":"https://api.github.com/users/targos/orgs","repos_url":"https://api.github.com/users/targos/repos","events_url":"https://api.github.com/users/targos/events{/privacy}","received_events_url":"https://api.github.com/users/targos/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":14,"state":"open","created_at":"2016-02-15T10:30:21Z","updated_at":"2016-08-29T07:41:54Z","due_on":"2016-09-30T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/nodejs/node/pulls/4039/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/4039/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/4039/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/3848eaee4e40547a25e587b6c6bedcd2e888cd10","head":{"label":"jscissr:simpler-listen","ref":"simpler-listen","sha":"3848eaee4e40547a25e587b6c6bedcd2e888cd10","user":{"login":"jscissr","id":4520820,"avatar_url":"https://avatars.githubusercontent.com/u/4520820?v=3","gravatar_id":"","url":"https://api.github.com/users/jscissr","html_url":"https://github.com/jscissr","followers_url":"https://api.github.com/users/jscissr/followers","following_url":"https://api.github.com/users/jscissr/following{/other_user}","gists_url":"https://api.github.com/users/jscissr/gists{/gist_id}","starred_url":"https://api.github.com/users/jscissr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jscissr/subscriptions","organizations_url":"https://api.github.com/users/jscissr/orgs","repos_url":"https://api.github.com/users/jscissr/repos","events_url":"https://api.github.com/users/jscissr/events{/privacy}","received_events_url":"https://api.github.com/users/jscissr/received_events","type":"User","site_admin":false},"repo":{"id":46581814,"name":"node","full_name":"jscissr/node","owner":{"login":"jscissr","id":4520820,"avatar_url":"https://avatars.githubusercontent.com/u/4520820?v=3","gravatar_id":"","url":"https://api.github.com/users/jscissr","html_url":"https://github.com/jscissr","followers_url":"https://api.github.com/users/jscissr/followers","following_url":"https://api.github.com/users/jscissr/following{/other_user}","gists_url":"https://api.github.com/users/jscissr/gists{/gist_id}","starred_url":"https://api.github.com/users/jscissr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jscissr/subscriptions","organizations_url":"https://api.github.com/users/jscissr/orgs","repos_url":"https://api.github.com/users/jscissr/repos","events_url":"https://api.github.com/users/jscissr/events{/privacy}","received_events_url":"https://api.github.com/users/jscissr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jscissr/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/jscissr/node","forks_url":"https://api.github.com/repos/jscissr/node/forks","keys_url":"https://api.github.com/repos/jscissr/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jscissr/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jscissr/node/teams","hooks_url":"https://api.github.com/repos/jscissr/node/hooks","issue_events_url":"https://api.github.com/repos/jscissr/node/issues/events{/number}","events_url":"https://api.github.com/repos/jscissr/node/events","assignees_url":"https://api.github.com/repos/jscissr/node/assignees{/user}","branches_url":"https://api.github.com/repos/jscissr/node/branches{/branch}","tags_url":"https://api.github.com/repos/jscissr/node/tags","blobs_url":"https://api.github.com/repos/jscissr/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jscissr/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jscissr/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/jscissr/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jscissr/node/statuses/{sha}","languages_url":"https://api.github.com/repos/jscissr/node/languages","stargazers_url":"https://api.github.com/repos/jscissr/node/stargazers","contributors_url":"https://api.github.com/repos/jscissr/node/contributors","subscribers_url":"https://api.github.com/repos/jscissr/node/subscribers","subscription_url":"https://api.github.com/repos/jscissr/node/subscription","commits_url":"https://api.github.com/repos/jscissr/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/jscissr/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/jscissr/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/jscissr/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/jscissr/node/contents/{+path}","compare_url":"https://api.github.com/repos/jscissr/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jscissr/node/merges","archive_url":"https://api.github.com/repos/jscissr/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jscissr/node/downloads","issues_url":"https://api.github.com/repos/jscissr/node/issues{/number}","pulls_url":"https://api.github.com/repos/jscissr/node/pulls{/number}","milestones_url":"https://api.github.com/repos/jscissr/node/milestones{/number}","notifications_url":"https://api.github.com/repos/jscissr/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jscissr/node/labels{/name}","releases_url":"https://api.github.com/repos/jscissr/node/releases{/id}","deployments_url":"https://api.github.com/repos/jscissr/node/deployments","created_at":"2015-11-20T19:18:50Z","updated_at":"2015-11-20T19:19:12Z","pushed_at":"2016-08-18T15:59:04Z","git_url":"git://github.com/jscissr/node.git","ssh_url":"git@github.com:jscissr/node.git","clone_url":"https://github.com/jscissr/node.git","svn_url":"https://github.com/jscissr/node","homepage":"https://nodejs.org","size":206488,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"f2fe5583c434e9864a1171209908c3a24b9d54bb","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2016-08-29T11:54:08Z","pushed_at":"2016-08-29T07:41:55Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":295580,"stargazers_count":26174,"watchers_count":26174,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4065,"mirror_url":null,"open_issues_count":766,"forks":4065,"open_issues":766,"watchers":26174,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/4039"},"html":{"href":"https://github.com/nodejs/node/pull/4039"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/4039"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/4039/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/4039/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/4039/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/3848eaee4e40547a25e587b6c6bedcd2e888cd10"}}}}
{"actor":{"display_login":"jscissr"}}