{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/io.js/issues/1935","labels_url":"https://api.github.com/repos/nodejs/io.js/issues/1935/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/io.js/issues/1935/comments","events_url":"https://api.github.com/repos/nodejs/io.js/issues/1935/events","html_url":"https://github.com/nodejs/io.js/pull/1935","id":86907598,"number":1935,"title":"util: display constructor name when inspecting objects","user":{"login":"monsanto","id":247721,"avatar_url":"https://avatars.githubusercontent.com/u/247721?v=3","gravatar_id":"","url":"https://api.github.com/users/monsanto","html_url":"https://github.com/monsanto","followers_url":"https://api.github.com/users/monsanto/followers","following_url":"https://api.github.com/users/monsanto/following{/other_user}","gists_url":"https://api.github.com/users/monsanto/gists{/gist_id}","starred_url":"https://api.github.com/users/monsanto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monsanto/subscriptions","organizations_url":"https://api.github.com/users/monsanto/orgs","repos_url":"https://api.github.com/users/monsanto/repos","events_url":"https://api.github.com/users/monsanto/events{/privacy}","received_events_url":"https://api.github.com/users/monsanto/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/io.js/labels/util","name":"util","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-06-10T09:45:11Z","updated_at":"2015-08-07T02:31:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/io.js/pulls/1935","html_url":"https://github.com/nodejs/io.js/pull/1935","diff_url":"https://github.com/nodejs/io.js/pull/1935.diff","patch_url":"https://github.com/nodejs/io.js/pull/1935.patch"},"body":"This feature is inspired by browser devtools. This PR modifies `util.inspect(obj)` to additionally show the name of the function that constructed the object. This often reveals useful information about the object's prototype. In other words, instead of\r\n\r\n```js\r\n> new Cls\r\n{}\r\n```\r\n\r\nwe have\r\n\r\n```js\r\n> new Cls\r\nCls {}\r\n```\r\n\r\nThis also works with exotic objects:\r\n\r\n```js\r\n> class ArrayCls extends Array {}\r\n> new ArrayCls(1, 2, 3)\r\nArrayCls [ 1, 2, 3 ]\r\n```\r\n\r\nThe names of \"trivial\" constructors like `Object` and `Array` are not shown, unless there is a mismatch between the object representation and the prototype:\r\n\r\n```js\r\n> Object.create([])\r\nArray {}\r\n```\r\n\r\nThe constructor displayed is the first function-valued 'constructor' property found by traversing the object and its prototypes. Anonymous functions and non-value descriptors are ignored. Note that cyclic prototypes are illegal so the search always terminates (unless one overrides `getPrototypeOf` with a proxy, but then I would argue you get what you deserve).\r\n\r\n---\r\n\r\nDisplay of boxed primitives is unchanged. One could imagine the following:\r\n\r\n```js\r\n> class NumberCls extends Number {}\r\n> new NumberCls(0)\r\n[NumberCls: 0]\r\n```\r\n\r\nbut right now, this will display `[Number: 0]`. This is largely because I am unhappy that the display of boxed primitives is inconsistent with how other exotic objects are displayed (Maps, Sets, Promises). But since boxed primitives are so rarely used this argument is ripe for bikeshedding and I would rather not have that stall the bulk of this feature."},"comment":{"url":"https://api.github.com/repos/nodejs/io.js/issues/comments/128566022","html_url":"https://github.com/nodejs/io.js/pull/1935#issuecomment-128566022","issue_url":"https://api.github.com/repos/nodejs/io.js/issues/1935","id":128566022,"user":{"login":"monsanto","id":247721,"avatar_url":"https://avatars.githubusercontent.com/u/247721?v=3","gravatar_id":"","url":"https://api.github.com/users/monsanto","html_url":"https://github.com/monsanto","followers_url":"https://api.github.com/users/monsanto/followers","following_url":"https://api.github.com/users/monsanto/following{/other_user}","gists_url":"https://api.github.com/users/monsanto/gists{/gist_id}","starred_url":"https://api.github.com/users/monsanto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monsanto/subscriptions","organizations_url":"https://api.github.com/users/monsanto/orgs","repos_url":"https://api.github.com/users/monsanto/repos","events_url":"https://api.github.com/users/monsanto/events{/privacy}","received_events_url":"https://api.github.com/users/monsanto/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T02:31:40Z","updated_at":"2015-08-07T02:31:40Z","body":"https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/228/"}}