{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/75407003","id":75407003,"diff_hunk":"@@ -236,41 +236,45 @@ The predefined color codes are: `white`, `grey`, `black`, `blue`, `cyan`,\n Color styling uses ANSI control codes that may not be supported on all\n terminals.\n \n-### Custom `inspect()` function on Objects\n+### Custom inspection functions on Objects\n \n <!-- type=misc -->\n \n-Objects may also define their own `inspect(depth, opts)` function that\n-`util.inspect()` will invoke and use the result of when inspecting the object:\n+Objects may also define their own `[util.inspect.Custom](depth, opts)`\n+(or, equivalently `inspect(depth, opts)`) function that `util.inspect()` will\n+invoke and use the result of when inspecting the object:\n \n ```js\n const util = require('util');\n \n const obj = { name: 'nate' };\n-obj.inspect = function(depth) {\n+obj[util.inspect.Custom] = function(depth) {\n   return `{${this.name}}`;\n };\n \n util.inspect(obj);\n   // \"{nate}\"\n ```\n \n-Custom `inspect(depth, opts)` functions typically return a string but may\n-return a value of any type that will be formatted accordingly by\n+Custom `[util.inspect.Custom](depth, opts)` functions typically return a string\n+but may return a value of any type that will be formatted accordingly by\n `util.inspect()`.\n \n ```js\n const util = require('util');\n \n const obj = { foo: 'this will not show up in the inspect() output' };\n-obj.inspect = function(depth) {\n+obj[util.inspect.Custom] = function(depth) {\n   return { bar: 'baz' };\n };\n \n util.inspect(obj);\n   // \"{ bar: 'baz' }\"\n ```\n \n+The same functionality can also be provided by `inspect(depth, opts)` when\n+no `util.inspect.Custom` method is present on an object.","path":"doc/api/util.md","position":48,"original_position":48,"commit_id":"e85abcb6bca8745bead72e7209795a03e55a06da","original_commit_id":"e85abcb6bca8745bead72e7209795a03e55a06da","user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"body":"Perhaps instead:\r\n```\r\nA custom inspection method can alternatively be provided by exposing\r\nan `inspect(depth, opts)` method on the object:\r\n```\r\n\r\nThen include the equivalent example.\r\n","created_at":"2016-08-18T23:25:12Z","updated_at":"2016-08-18T23:25:12Z","html_url":"https://github.com/nodejs/node/pull/8174#discussion_r75407003","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/8174","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/75407003"},"html":{"href":"https://github.com/nodejs/node/pull/8174#discussion_r75407003"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/8174"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/8174","id":81902762,"html_url":"https://github.com/nodejs/node/pull/8174","diff_url":"https://github.com/nodejs/node/pull/8174.diff","patch_url":"https://github.com/nodejs/node/pull/8174.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/8174","number":8174,"state":"open","locked":false,"title":"util: allow symbol-based custom inspection methods","user":{"login":"addaleax","id":899444,"avatar_url":"https://avatars.githubusercontent.com/u/899444?v=3","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"body":"##### Checklist\r\n\r\n- [x] `make -j4 test` (UNIX), or `vcbuild test nosign` (Windows) passes\r\n- [x] tests and/or benchmarks are included\r\n- [x] documentation is changed or added\r\n- [x] commit message follows commit guidelines\r\n\r\n##### Affected core subsystem(s)\r\n\r\nutil\r\n\r\n##### Description of change\r\n\r\nAdd a `util.inspect.Custom` Symbol which can be used to customize `util.inspect()` output. Providing `obj[util.inspect.Custom]` works like providing `obj.inspect`, except that the former allows avoiding name clashes with other `inspect()` methods.\r\n\r\nFixes: #8071\r\n\r\nI’d appreciate feedback both on the symbol’s name and the way I changed the docs on custom inspection functions.","created_at":"2016-08-18T23:02:48Z","updated_at":"2016-08-18T23:25:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7b7499c242450e73b94d45807dca679a9576a8d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/8174/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/8174/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/8174/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/e85abcb6bca8745bead72e7209795a03e55a06da","head":{"label":"addaleax:util-inspect-symbol2","ref":"util-inspect-symbol2","sha":"e85abcb6bca8745bead72e7209795a03e55a06da","user":{"login":"addaleax","id":899444,"avatar_url":"https://avatars.githubusercontent.com/u/899444?v=3","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"repo":{"id":47707342,"name":"node","full_name":"addaleax/node","owner":{"login":"addaleax","id":899444,"avatar_url":"https://avatars.githubusercontent.com/u/899444?v=3","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/addaleax/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/addaleax/node","forks_url":"https://api.github.com/repos/addaleax/node/forks","keys_url":"https://api.github.com/repos/addaleax/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/addaleax/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/addaleax/node/teams","hooks_url":"https://api.github.com/repos/addaleax/node/hooks","issue_events_url":"https://api.github.com/repos/addaleax/node/issues/events{/number}","events_url":"https://api.github.com/repos/addaleax/node/events","assignees_url":"https://api.github.com/repos/addaleax/node/assignees{/user}","branches_url":"https://api.github.com/repos/addaleax/node/branches{/branch}","tags_url":"https://api.github.com/repos/addaleax/node/tags","blobs_url":"https://api.github.com/repos/addaleax/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/addaleax/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/addaleax/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/addaleax/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/addaleax/node/statuses/{sha}","languages_url":"https://api.github.com/repos/addaleax/node/languages","stargazers_url":"https://api.github.com/repos/addaleax/node/stargazers","contributors_url":"https://api.github.com/repos/addaleax/node/contributors","subscribers_url":"https://api.github.com/repos/addaleax/node/subscribers","subscription_url":"https://api.github.com/repos/addaleax/node/subscription","commits_url":"https://api.github.com/repos/addaleax/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/addaleax/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/addaleax/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/addaleax/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/addaleax/node/contents/{+path}","compare_url":"https://api.github.com/repos/addaleax/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/addaleax/node/merges","archive_url":"https://api.github.com/repos/addaleax/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/addaleax/node/downloads","issues_url":"https://api.github.com/repos/addaleax/node/issues{/number}","pulls_url":"https://api.github.com/repos/addaleax/node/pulls{/number}","milestones_url":"https://api.github.com/repos/addaleax/node/milestones{/number}","notifications_url":"https://api.github.com/repos/addaleax/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/addaleax/node/labels{/name}","releases_url":"https://api.github.com/repos/addaleax/node/releases{/id}","deployments_url":"https://api.github.com/repos/addaleax/node/deployments","created_at":"2015-12-09T17:26:30Z","updated_at":"2016-03-24T02:52:12Z","pushed_at":"2016-08-18T22:58:34Z","git_url":"git://github.com/addaleax/node.git","ssh_url":"git@github.com:addaleax/node.git","clone_url":"https://github.com/addaleax/node.git","svn_url":"https://github.com/addaleax/node","homepage":"https://nodejs.org","size":215578,"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":"ae0334a7e7b51eede504c29bf3107586a65ec27c","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-18T22:46:33Z","pushed_at":"2016-08-18T23:17:42Z","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":290536,"stargazers_count":25863,"watchers_count":25863,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3973,"mirror_url":null,"open_issues_count":746,"forks":3973,"open_issues":746,"watchers":25863,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/8174"},"html":{"href":"https://github.com/nodejs/node/pull/8174"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/8174"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/8174/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/8174/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/8174/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/e85abcb6bca8745bead72e7209795a03e55a06da"}}}}
{"actor":{"display_login":"jasnell"}}