{"action":"created","comment":{"url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/comments/67085527","id":67085527,"diff_hunk":"@@ -0,0 +1,61 @@\n+var reactTestInstance = Symbol.for('react.test.json');\n+\n+function handleChildren(result, children, indentation, print, indent) {\n+  if (children) {\n+    children.forEach(function(child) {\n+      result.push('\\n');\n+      result.push(objectToJSX(child, indentation, print, indent));\n+    });\n+    result.push('\\n');\n+  }\n+}\n+\n+function handleProps(result, node, indentation, print, indent) {\n+  var props = node.props;\n+  if (props) {\n+    var indentOpts = {\n+      indent: 2 * (indentation + 1)\n+    };\n+    Object.keys(props).forEach(function(prop) {\n+      result.push('\\n', indent(prop, indentOpts), '=');\n+      var value = props[prop];\n+      if (typeof value === 'string') {\n+        result.push('\"', value, '\"');\n+      } else {\n+        var formatted = indent(print(value), {indent: 2 * (indentation + 2)});\n+        result.push('{\\n', formatted, '\\n', indent('}', indentOpts));\n+      }\n+    });\n+  }\n+}\n+\n+function objectToJSX(root, indentation, print, indent) {\n+  indentation = indentation || 0;\n+  var indentationOpts = {indent: indentation * 2};\n+  var type = root.type;\n+  if (!type && typeof root === 'string'){\n+    return indent(root, indentationOpts);\n+  }\n+  var result = [];\n+  if (!root.children) {\n+    result.push(indent('<', indentationOpts), type);\n+    handleProps(result, root, indentation, print, indent);\n+    result.push(' />');\n+  } else {\n+    result.push(indent('<', indentationOpts), type);\n+    handleProps(result, root, indentation, print, indent);\n+    result.push('>');\n+    handleChildren(result, root.children, indentation + 1, print, indent);\n+    result.push(indent('</', indentationOpts), type, '>');\n+  }\n+  return result.join('');","path":"plugins/ReactTestComponent.js","position":51,"original_position":51,"commit_id":"1b46d05ad31c6b0767790e3d44452721efb028c5","original_commit_id":"1b46d05ad31c6b0767790e3d44452721efb028c5","user":{"login":"cpojer","id":13352,"avatar_url":"https://avatars.githubusercontent.com/u/13352?v=3","gravatar_id":"","url":"https://api.github.com/users/cpojer","html_url":"https://github.com/cpojer","followers_url":"https://api.github.com/users/cpojer/followers","following_url":"https://api.github.com/users/cpojer/following{/other_user}","gists_url":"https://api.github.com/users/cpojer/gists{/gist_id}","starred_url":"https://api.github.com/users/cpojer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpojer/subscriptions","organizations_url":"https://api.github.com/users/cpojer/orgs","repos_url":"https://api.github.com/users/cpojer/repos","events_url":"https://api.github.com/users/cpojer/events{/privacy}","received_events_url":"https://api.github.com/users/cpojer/received_events","type":"User","site_admin":false},"body":"At Facebook we usually resolve it this way:\r\n\r\n* use the most concise style or stick with what the project does (strings in this case)\r\n* prove that in the engine that matters the most (node 4 or 6, which we use internally at FB right now) the other solution is much faster.","created_at":"2016-06-15T01:12:51Z","updated_at":"2016-06-15T01:12:51Z","html_url":"https://github.com/thejameskyle/pretty-format/pull/10#discussion_r67085527","pull_request_url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/comments/67085527"},"html":{"href":"https://github.com/thejameskyle/pretty-format/pull/10#discussion_r67085527"},"pull_request":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10","id":73823704,"html_url":"https://github.com/thejameskyle/pretty-format/pull/10","diff_url":"https://github.com/thejameskyle/pretty-format/pull/10.diff","patch_url":"https://github.com/thejameskyle/pretty-format/pull/10.patch","issue_url":"https://api.github.com/repos/thejameskyle/pretty-format/issues/10","number":10,"state":"open","locked":false,"title":"ReactTestRenderer plugin first version","user":{"login":"kentaromiura","id":87300,"avatar_url":"https://avatars.githubusercontent.com/u/87300?v=3","gravatar_id":"","url":"https://api.github.com/users/kentaromiura","html_url":"https://github.com/kentaromiura","followers_url":"https://api.github.com/users/kentaromiura/followers","following_url":"https://api.github.com/users/kentaromiura/following{/other_user}","gists_url":"https://api.github.com/users/kentaromiura/gists{/gist_id}","starred_url":"https://api.github.com/users/kentaromiura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentaromiura/subscriptions","organizations_url":"https://api.github.com/users/kentaromiura/orgs","repos_url":"https://api.github.com/users/kentaromiura/repos","events_url":"https://api.github.com/users/kentaromiura/events{/privacy}","received_events_url":"https://api.github.com/users/kentaromiura/received_events","type":"User","site_admin":false},"body":"This is a rough first version of a jsx-like pretty printed that I wrote in the last week based on the latest ReactTestRenderer, I just changed it to work with latest version of pretty-format, I added a little test I wrote to ensure the indentation works fine, it can now probably be improved (for example I think I may be using the boundIndent function)\r\nThis is what the last test will generate:\r\n```\r\n<Mouse\r\n  customProp={\r\n    Object {\r\n      \"one\": \"1\",\r\n      \"two\": 2\r\n    }\r\n  }\r\n  onclick={\r\n    function (){}\r\n  }>\r\n  HELLO\r\n  <Mouse\r\n    customProp={\r\n      Object {\r\n        \"one\": \"1\",\r\n        \"two\": 2\r\n      }\r\n    }\r\n    onclick={\r\n      function (){}\r\n    }>\r\n    HELLO\r\n    <Mouse />\r\n    CIAO\r\n  </Mouse>\r\n  CIAO\r\n</Mouse>\r\n```","created_at":"2016-06-14T22:19:20Z","updated_at":"2016-06-15T01:12:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fca948f9d0abbe4ebad21cfd745c0d63614bb38f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10/commits","review_comments_url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10/comments","review_comment_url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thejameskyle/pretty-format/issues/10/comments","statuses_url":"https://api.github.com/repos/thejameskyle/pretty-format/statuses/1b46d05ad31c6b0767790e3d44452721efb028c5","head":{"label":"kentaromiura:ReactTestComponent","ref":"ReactTestComponent","sha":"1b46d05ad31c6b0767790e3d44452721efb028c5","user":{"login":"kentaromiura","id":87300,"avatar_url":"https://avatars.githubusercontent.com/u/87300?v=3","gravatar_id":"","url":"https://api.github.com/users/kentaromiura","html_url":"https://github.com/kentaromiura","followers_url":"https://api.github.com/users/kentaromiura/followers","following_url":"https://api.github.com/users/kentaromiura/following{/other_user}","gists_url":"https://api.github.com/users/kentaromiura/gists{/gist_id}","starred_url":"https://api.github.com/users/kentaromiura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentaromiura/subscriptions","organizations_url":"https://api.github.com/users/kentaromiura/orgs","repos_url":"https://api.github.com/users/kentaromiura/repos","events_url":"https://api.github.com/users/kentaromiura/events{/privacy}","received_events_url":"https://api.github.com/users/kentaromiura/received_events","type":"User","site_admin":false},"repo":{"id":61079427,"name":"pretty-format","full_name":"kentaromiura/pretty-format","owner":{"login":"kentaromiura","id":87300,"avatar_url":"https://avatars.githubusercontent.com/u/87300?v=3","gravatar_id":"","url":"https://api.github.com/users/kentaromiura","html_url":"https://github.com/kentaromiura","followers_url":"https://api.github.com/users/kentaromiura/followers","following_url":"https://api.github.com/users/kentaromiura/following{/other_user}","gists_url":"https://api.github.com/users/kentaromiura/gists{/gist_id}","starred_url":"https://api.github.com/users/kentaromiura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentaromiura/subscriptions","organizations_url":"https://api.github.com/users/kentaromiura/orgs","repos_url":"https://api.github.com/users/kentaromiura/repos","events_url":"https://api.github.com/users/kentaromiura/events{/privacy}","received_events_url":"https://api.github.com/users/kentaromiura/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kentaromiura/pretty-format","description":"Stringify any JavaScript value","fork":true,"url":"https://api.github.com/repos/kentaromiura/pretty-format","forks_url":"https://api.github.com/repos/kentaromiura/pretty-format/forks","keys_url":"https://api.github.com/repos/kentaromiura/pretty-format/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kentaromiura/pretty-format/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kentaromiura/pretty-format/teams","hooks_url":"https://api.github.com/repos/kentaromiura/pretty-format/hooks","issue_events_url":"https://api.github.com/repos/kentaromiura/pretty-format/issues/events{/number}","events_url":"https://api.github.com/repos/kentaromiura/pretty-format/events","assignees_url":"https://api.github.com/repos/kentaromiura/pretty-format/assignees{/user}","branches_url":"https://api.github.com/repos/kentaromiura/pretty-format/branches{/branch}","tags_url":"https://api.github.com/repos/kentaromiura/pretty-format/tags","blobs_url":"https://api.github.com/repos/kentaromiura/pretty-format/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kentaromiura/pretty-format/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kentaromiura/pretty-format/git/refs{/sha}","trees_url":"https://api.github.com/repos/kentaromiura/pretty-format/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kentaromiura/pretty-format/statuses/{sha}","languages_url":"https://api.github.com/repos/kentaromiura/pretty-format/languages","stargazers_url":"https://api.github.com/repos/kentaromiura/pretty-format/stargazers","contributors_url":"https://api.github.com/repos/kentaromiura/pretty-format/contributors","subscribers_url":"https://api.github.com/repos/kentaromiura/pretty-format/subscribers","subscription_url":"https://api.github.com/repos/kentaromiura/pretty-format/subscription","commits_url":"https://api.github.com/repos/kentaromiura/pretty-format/commits{/sha}","git_commits_url":"https://api.github.com/repos/kentaromiura/pretty-format/git/commits{/sha}","comments_url":"https://api.github.com/repos/kentaromiura/pretty-format/comments{/number}","issue_comment_url":"https://api.github.com/repos/kentaromiura/pretty-format/issues/comments{/number}","contents_url":"https://api.github.com/repos/kentaromiura/pretty-format/contents/{+path}","compare_url":"https://api.github.com/repos/kentaromiura/pretty-format/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kentaromiura/pretty-format/merges","archive_url":"https://api.github.com/repos/kentaromiura/pretty-format/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kentaromiura/pretty-format/downloads","issues_url":"https://api.github.com/repos/kentaromiura/pretty-format/issues{/number}","pulls_url":"https://api.github.com/repos/kentaromiura/pretty-format/pulls{/number}","milestones_url":"https://api.github.com/repos/kentaromiura/pretty-format/milestones{/number}","notifications_url":"https://api.github.com/repos/kentaromiura/pretty-format/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kentaromiura/pretty-format/labels{/name}","releases_url":"https://api.github.com/repos/kentaromiura/pretty-format/releases{/id}","deployments_url":"https://api.github.com/repos/kentaromiura/pretty-format/deployments","created_at":"2016-06-14T00:41:27Z","updated_at":"2016-06-14T00:41:29Z","pushed_at":"2016-06-15T00:00:19Z","git_url":"git://github.com/kentaromiura/pretty-format.git","ssh_url":"git@github.com:kentaromiura/pretty-format.git","clone_url":"https://github.com/kentaromiura/pretty-format.git","svn_url":"https://github.com/kentaromiura/pretty-format","homepage":null,"size":53,"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":"thejameskyle:master","ref":"master","sha":"bc0c4d481a51204724019a526c9164eaa48817ed","user":{"login":"thejameskyle","id":952783,"avatar_url":"https://avatars.githubusercontent.com/u/952783?v=3","gravatar_id":"","url":"https://api.github.com/users/thejameskyle","html_url":"https://github.com/thejameskyle","followers_url":"https://api.github.com/users/thejameskyle/followers","following_url":"https://api.github.com/users/thejameskyle/following{/other_user}","gists_url":"https://api.github.com/users/thejameskyle/gists{/gist_id}","starred_url":"https://api.github.com/users/thejameskyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejameskyle/subscriptions","organizations_url":"https://api.github.com/users/thejameskyle/orgs","repos_url":"https://api.github.com/users/thejameskyle/repos","events_url":"https://api.github.com/users/thejameskyle/events{/privacy}","received_events_url":"https://api.github.com/users/thejameskyle/received_events","type":"User","site_admin":false},"repo":{"id":31834705,"name":"pretty-format","full_name":"thejameskyle/pretty-format","owner":{"login":"thejameskyle","id":952783,"avatar_url":"https://avatars.githubusercontent.com/u/952783?v=3","gravatar_id":"","url":"https://api.github.com/users/thejameskyle","html_url":"https://github.com/thejameskyle","followers_url":"https://api.github.com/users/thejameskyle/followers","following_url":"https://api.github.com/users/thejameskyle/following{/other_user}","gists_url":"https://api.github.com/users/thejameskyle/gists{/gist_id}","starred_url":"https://api.github.com/users/thejameskyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejameskyle/subscriptions","organizations_url":"https://api.github.com/users/thejameskyle/orgs","repos_url":"https://api.github.com/users/thejameskyle/repos","events_url":"https://api.github.com/users/thejameskyle/events{/privacy}","received_events_url":"https://api.github.com/users/thejameskyle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thejameskyle/pretty-format","description":"Stringify any JavaScript value","fork":false,"url":"https://api.github.com/repos/thejameskyle/pretty-format","forks_url":"https://api.github.com/repos/thejameskyle/pretty-format/forks","keys_url":"https://api.github.com/repos/thejameskyle/pretty-format/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thejameskyle/pretty-format/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thejameskyle/pretty-format/teams","hooks_url":"https://api.github.com/repos/thejameskyle/pretty-format/hooks","issue_events_url":"https://api.github.com/repos/thejameskyle/pretty-format/issues/events{/number}","events_url":"https://api.github.com/repos/thejameskyle/pretty-format/events","assignees_url":"https://api.github.com/repos/thejameskyle/pretty-format/assignees{/user}","branches_url":"https://api.github.com/repos/thejameskyle/pretty-format/branches{/branch}","tags_url":"https://api.github.com/repos/thejameskyle/pretty-format/tags","blobs_url":"https://api.github.com/repos/thejameskyle/pretty-format/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thejameskyle/pretty-format/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thejameskyle/pretty-format/git/refs{/sha}","trees_url":"https://api.github.com/repos/thejameskyle/pretty-format/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thejameskyle/pretty-format/statuses/{sha}","languages_url":"https://api.github.com/repos/thejameskyle/pretty-format/languages","stargazers_url":"https://api.github.com/repos/thejameskyle/pretty-format/stargazers","contributors_url":"https://api.github.com/repos/thejameskyle/pretty-format/contributors","subscribers_url":"https://api.github.com/repos/thejameskyle/pretty-format/subscribers","subscription_url":"https://api.github.com/repos/thejameskyle/pretty-format/subscription","commits_url":"https://api.github.com/repos/thejameskyle/pretty-format/commits{/sha}","git_commits_url":"https://api.github.com/repos/thejameskyle/pretty-format/git/commits{/sha}","comments_url":"https://api.github.com/repos/thejameskyle/pretty-format/comments{/number}","issue_comment_url":"https://api.github.com/repos/thejameskyle/pretty-format/issues/comments{/number}","contents_url":"https://api.github.com/repos/thejameskyle/pretty-format/contents/{+path}","compare_url":"https://api.github.com/repos/thejameskyle/pretty-format/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thejameskyle/pretty-format/merges","archive_url":"https://api.github.com/repos/thejameskyle/pretty-format/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thejameskyle/pretty-format/downloads","issues_url":"https://api.github.com/repos/thejameskyle/pretty-format/issues{/number}","pulls_url":"https://api.github.com/repos/thejameskyle/pretty-format/pulls{/number}","milestones_url":"https://api.github.com/repos/thejameskyle/pretty-format/milestones{/number}","notifications_url":"https://api.github.com/repos/thejameskyle/pretty-format/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thejameskyle/pretty-format/labels{/name}","releases_url":"https://api.github.com/repos/thejameskyle/pretty-format/releases{/id}","deployments_url":"https://api.github.com/repos/thejameskyle/pretty-format/deployments","created_at":"2015-03-08T01:41:37Z","updated_at":"2016-06-02T02:53:22Z","pushed_at":"2016-06-15T00:00:19Z","git_url":"git://github.com/thejameskyle/pretty-format.git","ssh_url":"git@github.com:thejameskyle/pretty-format.git","clone_url":"https://github.com/thejameskyle/pretty-format.git","svn_url":"https://github.com/thejameskyle/pretty-format","homepage":null,"size":58,"stargazers_count":25,"watchers_count":25,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10"},"html":{"href":"https://github.com/thejameskyle/pretty-format/pull/10"},"issue":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/issues/10"},"comments":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/thejameskyle/pretty-format/statuses/1b46d05ad31c6b0767790e3d44452721efb028c5"}}}}
{"actor":{"display_login":"cpojer"}}