{"action":"created","comment":{"url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/comments/32840122","id":32840122,"diff_hunk":"@@ -0,0 +1,70 @@\n+/*\n+* Tests if an object is like another. This means objects should follow the same\n+* structure and arrays should contain the same types.\n+*\n+* E.g.\n+*\n+* _.islike(\n+*   {name: \"James\", age: 10, hobbies: [\"football\", \"computer games\", \"baking\"]},\n+*   {name: \"\", age: 0, hobbies: [\"\"]}\n+* )\n+*/\n+(function() {\n+  // Establish the root object, `window` in the browser, or `require` it on the server.\n+  if (typeof exports === 'object') {\n+    _ = module.exports = require('underscore');\n+  }\n+\n+    var islike = function(obj, pattern) {\n+        if (typeof pattern === \"function\") {\n+            return obj instanceof pattern;\n+        }\n+\n+        if (typeof obj !== typeof pattern) return false;\n+            if (pattern instanceof Array && !(obj instanceof Array)) return false;\n+\n+                var type = typeof pattern;\n+\n+                if (type == \"object\") {\n+                    if (pattern instanceof Array) {\n+                        if (pattern.length > 0) {\n+                            var oTypes = _.uniq(_.map(obj, fTypeof));\n+                            var pTypes = _.uniq(_.map(pattern, fTypeof));\n+                            if (_.difference(oTypes, pTypes).length) {\n+                                return false;\n+                            }\n+                        }\n+                    } else { // object\n+                        if (pattern.constructor === pattern.constructor.prototype.constructor) {\n+                            // for 'simple' objects we enumerate\n+                            for (var k in pattern) {\n+                                if (!pattern.hasOwnProperty(k)) {","path":"underscore.comparison.islike.js","position":41,"original_position":41,"commit_id":"cc17ec0897116fc19d7c23d8b910bc566c69e5ea","original_commit_id":"cc17ec0897116fc19d7c23d8b910bc566c69e5ea","user":{"login":"megawac","id":3475472,"avatar_url":"https://avatars.githubusercontent.com/u/3475472?v=3","gravatar_id":"","url":"https://api.github.com/users/megawac","html_url":"https://github.com/megawac","followers_url":"https://api.github.com/users/megawac/followers","following_url":"https://api.github.com/users/megawac/following{/other_user}","gists_url":"https://api.github.com/users/megawac/gists{/gist_id}","starred_url":"https://api.github.com/users/megawac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megawac/subscriptions","organizations_url":"https://api.github.com/users/megawac/orgs","repos_url":"https://api.github.com/users/megawac/repos","events_url":"https://api.github.com/users/megawac/events{/privacy}","received_events_url":"https://api.github.com/users/megawac/received_events","type":"User","site_admin":false},"body":"Sorry, the official name for `_.any` is _.some (any is an alias)\n\nOn Fri, Jun 19, 2015 at 11:20 AM, Joe Bain <notifications@github.com> wrote:\n\n> In underscore.comparison.islike.js\n> <https://github.com/documentcloud/underscore-contrib/pull/196#discussion_r32838824>\n> :\n>\n> > +                var type = typeof pattern;\n> > +\n> > +                if (type == \"object\") {\n> > +                    if (pattern instanceof Array) {\n> > +                        if (pattern.length > 0) {\n> > +                            var oTypes = _.uniq(_.map(obj, fTypeof));\n> > +                            var pTypes = _.uniq(_.map(pattern, fTypeof));\n> > +                            if (_.difference(oTypes, pTypes).length) {\n> > +                                return false;\n> > +                            }\n> > +                        }\n> > +                    } else { // object\n> > +                        if (pattern.constructor === pattern.constructor.prototype.constructor) {\n> > +                            // for 'simple' objects we enumerate\n> > +                            for (var k in pattern) {\n> > +                                if (!pattern.hasOwnProperty(k)) {\n>\n> Sorry, I can't find _.any in underscore or contrib. I think I'm being\n> blind, where is that?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/documentcloud/underscore-contrib/pull/196/files#r32838824>\n> .\n>\n","created_at":"2015-06-19T15:34:00Z","updated_at":"2015-06-19T15:34:00Z","html_url":"https://github.com/documentcloud/underscore-contrib/pull/196#discussion_r32840122","pull_request_url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196","_links":{"self":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/comments/32840122"},"html":{"href":"https://github.com/documentcloud/underscore-contrib/pull/196#discussion_r32840122"},"pull_request":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196"}}},"pull_request":{"url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196","id":38115500,"html_url":"https://github.com/documentcloud/underscore-contrib/pull/196","diff_url":"https://github.com/documentcloud/underscore-contrib/pull/196.diff","patch_url":"https://github.com/documentcloud/underscore-contrib/pull/196.patch","issue_url":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/196","number":196,"state":"open","locked":false,"title":"_.islike(obj, pattern) tests objects are like patterns","user":{"login":"joebain","id":178859,"avatar_url":"https://avatars.githubusercontent.com/u/178859?v=3","gravatar_id":"","url":"https://api.github.com/users/joebain","html_url":"https://github.com/joebain","followers_url":"https://api.github.com/users/joebain/followers","following_url":"https://api.github.com/users/joebain/following{/other_user}","gists_url":"https://api.github.com/users/joebain/gists{/gist_id}","starred_url":"https://api.github.com/users/joebain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joebain/subscriptions","organizations_url":"https://api.github.com/users/joebain/orgs","repos_url":"https://api.github.com/users/joebain/repos","events_url":"https://api.github.com/users/joebain/events{/privacy}","received_events_url":"https://api.github.com/users/joebain/received_events","type":"User","site_admin":false},"body":"The impetus behind this function is to check arguments received are in the expected format and be able to show an error or do other appropriate actions if not.\r\n\r\n```\r\n_.islike(\r\n  {name: \"James\", age: 10, hobbies: [\"football\", \"computer games\", \"baking\"]},\r\n  {name: \"\", age: 0, hobbies: [\"\"]}\r\n)\r\n```\r\n\r\nPlease check the docs for a more thorough description and let me know what you think.","created_at":"2015-06-19T14:55:27Z","updated_at":"2015-06-19T15:34:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f8032e231e4ba96f90bbf4a5d651999017ea310","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196/commits","review_comments_url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196/comments","review_comment_url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/196/comments","statuses_url":"https://api.github.com/repos/documentcloud/underscore-contrib/statuses/cc17ec0897116fc19d7c23d8b910bc566c69e5ea","head":{"label":"joebain:master","ref":"master","sha":"cc17ec0897116fc19d7c23d8b910bc566c69e5ea","user":{"login":"joebain","id":178859,"avatar_url":"https://avatars.githubusercontent.com/u/178859?v=3","gravatar_id":"","url":"https://api.github.com/users/joebain","html_url":"https://github.com/joebain","followers_url":"https://api.github.com/users/joebain/followers","following_url":"https://api.github.com/users/joebain/following{/other_user}","gists_url":"https://api.github.com/users/joebain/gists{/gist_id}","starred_url":"https://api.github.com/users/joebain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joebain/subscriptions","organizations_url":"https://api.github.com/users/joebain/orgs","repos_url":"https://api.github.com/users/joebain/repos","events_url":"https://api.github.com/users/joebain/events{/privacy}","received_events_url":"https://api.github.com/users/joebain/received_events","type":"User","site_admin":false},"repo":{"id":37727390,"name":"underscore-contrib","full_name":"joebain/underscore-contrib","owner":{"login":"joebain","id":178859,"avatar_url":"https://avatars.githubusercontent.com/u/178859?v=3","gravatar_id":"","url":"https://api.github.com/users/joebain","html_url":"https://github.com/joebain","followers_url":"https://api.github.com/users/joebain/followers","following_url":"https://api.github.com/users/joebain/following{/other_user}","gists_url":"https://api.github.com/users/joebain/gists{/gist_id}","starred_url":"https://api.github.com/users/joebain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joebain/subscriptions","organizations_url":"https://api.github.com/users/joebain/orgs","repos_url":"https://api.github.com/users/joebain/repos","events_url":"https://api.github.com/users/joebain/events{/privacy}","received_events_url":"https://api.github.com/users/joebain/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joebain/underscore-contrib","description":"The brass buckles on Underscore's utility belt","fork":true,"url":"https://api.github.com/repos/joebain/underscore-contrib","forks_url":"https://api.github.com/repos/joebain/underscore-contrib/forks","keys_url":"https://api.github.com/repos/joebain/underscore-contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joebain/underscore-contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joebain/underscore-contrib/teams","hooks_url":"https://api.github.com/repos/joebain/underscore-contrib/hooks","issue_events_url":"https://api.github.com/repos/joebain/underscore-contrib/issues/events{/number}","events_url":"https://api.github.com/repos/joebain/underscore-contrib/events","assignees_url":"https://api.github.com/repos/joebain/underscore-contrib/assignees{/user}","branches_url":"https://api.github.com/repos/joebain/underscore-contrib/branches{/branch}","tags_url":"https://api.github.com/repos/joebain/underscore-contrib/tags","blobs_url":"https://api.github.com/repos/joebain/underscore-contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joebain/underscore-contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joebain/underscore-contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/joebain/underscore-contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joebain/underscore-contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/joebain/underscore-contrib/languages","stargazers_url":"https://api.github.com/repos/joebain/underscore-contrib/stargazers","contributors_url":"https://api.github.com/repos/joebain/underscore-contrib/contributors","subscribers_url":"https://api.github.com/repos/joebain/underscore-contrib/subscribers","subscription_url":"https://api.github.com/repos/joebain/underscore-contrib/subscription","commits_url":"https://api.github.com/repos/joebain/underscore-contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/joebain/underscore-contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/joebain/underscore-contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/joebain/underscore-contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/joebain/underscore-contrib/contents/{+path}","compare_url":"https://api.github.com/repos/joebain/underscore-contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joebain/underscore-contrib/merges","archive_url":"https://api.github.com/repos/joebain/underscore-contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joebain/underscore-contrib/downloads","issues_url":"https://api.github.com/repos/joebain/underscore-contrib/issues{/number}","pulls_url":"https://api.github.com/repos/joebain/underscore-contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/joebain/underscore-contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/joebain/underscore-contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joebain/underscore-contrib/labels{/name}","releases_url":"https://api.github.com/repos/joebain/underscore-contrib/releases{/id}","created_at":"2015-06-19T14:48:42Z","updated_at":"2015-06-19T14:48:43Z","pushed_at":"2015-06-19T14:54:51Z","git_url":"git://github.com/joebain/underscore-contrib.git","ssh_url":"git@github.com:joebain/underscore-contrib.git","clone_url":"https://github.com/joebain/underscore-contrib.git","svn_url":"https://github.com/joebain/underscore-contrib","homepage":null,"size":2683,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"documentcloud:master","ref":"master","sha":"1492ffbe04a62a838da89df6ebdf77d0ed0b9844","user":{"login":"documentcloud","id":93383,"avatar_url":"https://avatars.githubusercontent.com/u/93383?v=3","gravatar_id":"","url":"https://api.github.com/users/documentcloud","html_url":"https://github.com/documentcloud","followers_url":"https://api.github.com/users/documentcloud/followers","following_url":"https://api.github.com/users/documentcloud/following{/other_user}","gists_url":"https://api.github.com/users/documentcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/documentcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/documentcloud/subscriptions","organizations_url":"https://api.github.com/users/documentcloud/orgs","repos_url":"https://api.github.com/users/documentcloud/repos","events_url":"https://api.github.com/users/documentcloud/events{/privacy}","received_events_url":"https://api.github.com/users/documentcloud/received_events","type":"Organization","site_admin":false},"repo":{"id":9502094,"name":"underscore-contrib","full_name":"documentcloud/underscore-contrib","owner":{"login":"documentcloud","id":93383,"avatar_url":"https://avatars.githubusercontent.com/u/93383?v=3","gravatar_id":"","url":"https://api.github.com/users/documentcloud","html_url":"https://github.com/documentcloud","followers_url":"https://api.github.com/users/documentcloud/followers","following_url":"https://api.github.com/users/documentcloud/following{/other_user}","gists_url":"https://api.github.com/users/documentcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/documentcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/documentcloud/subscriptions","organizations_url":"https://api.github.com/users/documentcloud/orgs","repos_url":"https://api.github.com/users/documentcloud/repos","events_url":"https://api.github.com/users/documentcloud/events{/privacy}","received_events_url":"https://api.github.com/users/documentcloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/documentcloud/underscore-contrib","description":"The brass buckles on Underscore's utility belt","fork":false,"url":"https://api.github.com/repos/documentcloud/underscore-contrib","forks_url":"https://api.github.com/repos/documentcloud/underscore-contrib/forks","keys_url":"https://api.github.com/repos/documentcloud/underscore-contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/documentcloud/underscore-contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/documentcloud/underscore-contrib/teams","hooks_url":"https://api.github.com/repos/documentcloud/underscore-contrib/hooks","issue_events_url":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/events{/number}","events_url":"https://api.github.com/repos/documentcloud/underscore-contrib/events","assignees_url":"https://api.github.com/repos/documentcloud/underscore-contrib/assignees{/user}","branches_url":"https://api.github.com/repos/documentcloud/underscore-contrib/branches{/branch}","tags_url":"https://api.github.com/repos/documentcloud/underscore-contrib/tags","blobs_url":"https://api.github.com/repos/documentcloud/underscore-contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/documentcloud/underscore-contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/documentcloud/underscore-contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/documentcloud/underscore-contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/documentcloud/underscore-contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/documentcloud/underscore-contrib/languages","stargazers_url":"https://api.github.com/repos/documentcloud/underscore-contrib/stargazers","contributors_url":"https://api.github.com/repos/documentcloud/underscore-contrib/contributors","subscribers_url":"https://api.github.com/repos/documentcloud/underscore-contrib/subscribers","subscription_url":"https://api.github.com/repos/documentcloud/underscore-contrib/subscription","commits_url":"https://api.github.com/repos/documentcloud/underscore-contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/documentcloud/underscore-contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/documentcloud/underscore-contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/documentcloud/underscore-contrib/contents/{+path}","compare_url":"https://api.github.com/repos/documentcloud/underscore-contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/documentcloud/underscore-contrib/merges","archive_url":"https://api.github.com/repos/documentcloud/underscore-contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/documentcloud/underscore-contrib/downloads","issues_url":"https://api.github.com/repos/documentcloud/underscore-contrib/issues{/number}","pulls_url":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/documentcloud/underscore-contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/documentcloud/underscore-contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/documentcloud/underscore-contrib/labels{/name}","releases_url":"https://api.github.com/repos/documentcloud/underscore-contrib/releases{/id}","created_at":"2013-04-17T16:24:16Z","updated_at":"2015-06-16T05:03:25Z","pushed_at":"2015-06-19T14:55:27Z","git_url":"git://github.com/documentcloud/underscore-contrib.git","ssh_url":"git@github.com:documentcloud/underscore-contrib.git","clone_url":"https://github.com/documentcloud/underscore-contrib.git","svn_url":"https://github.com/documentcloud/underscore-contrib","homepage":null,"size":4001,"stargazers_count":541,"watchers_count":541,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":92,"mirror_url":null,"open_issues_count":34,"forks":92,"open_issues":34,"watchers":541,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196"},"html":{"href":"https://github.com/documentcloud/underscore-contrib/pull/196"},"issue":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/196"},"comments":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/issues/196/comments"},"review_comments":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196/comments"},"review_comment":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/pulls/196/commits"},"statuses":{"href":"https://api.github.com/repos/documentcloud/underscore-contrib/statuses/cc17ec0897116fc19d7c23d8b910bc566c69e5ea"}}}}