{"action":"reopened","number":174,"pull_request":{"url":"https://api.github.com/repos/mozilla/rhino/pulls/174","id":33729397,"html_url":"https://github.com/mozilla/rhino/pull/174","diff_url":"https://github.com/mozilla/rhino/pull/174.diff","patch_url":"https://github.com/mozilla/rhino/pull/174.patch","issue_url":"https://api.github.com/repos/mozilla/rhino/issues/174","number":174,"state":"open","locked":false,"title":"Fix some issues with Array.prototype.{find, findIndex}","user":{"login":"sainaen","id":2400185,"avatar_url":"https://avatars.githubusercontent.com/u/2400185?v=3","gravatar_id":"","url":"https://api.github.com/users/sainaen","html_url":"https://github.com/sainaen","followers_url":"https://api.github.com/users/sainaen/followers","following_url":"https://api.github.com/users/sainaen/following{/other_user}","gists_url":"https://api.github.com/users/sainaen/gists{/gist_id}","starred_url":"https://api.github.com/users/sainaen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sainaen/subscriptions","organizations_url":"https://api.github.com/users/sainaen/orgs","repos_url":"https://api.github.com/users/sainaen/repos","events_url":"https://api.github.com/users/sainaen/events{/privacy}","received_events_url":"https://api.github.com/users/sainaen/received_events","type":"User","site_admin":false},"body":"Fixes for apigee/rhino#24\r\n\r\n### Done\r\n- Don't skip holes in sparse arrays:\r\n```\r\nvar a = [];\r\na[10] = 1;\r\nvar l = 0;\r\na.find(predicate);\r\nassertEquals(a.length, l);\r\n```\r\n- Allow passing array itself as `thisArg`:\r\n```js\r\nvar a = [1, 2];\r\nvar o;\r\na.findIndex(function () { o = this; }, a);\r\nassertEquals(a, o);\r\n```\r\n- Allow passing any instance of Function, but do not allow RegExp-s:\r\n```js\r\nvar a = [21, 22, 23, 24];\r\n\r\n// `InterpretedFunction` or `? extends NativeFunction`\r\nassertEquals(a[0], a.find(function () { return true; }));\r\n// `IdScriptableObject`\r\nassertEquals(a[0], a.find(Object.prototype.toString));\r\nassertEquals(a[0], a.find(String));\r\n// `BoundFunction`\r\nassertEquals(a[0], a.find((function () { return true; }).bind({})))\r\n// `NativeRegExp`\r\nassertThrows('Array.prototype.findIndex.apply(a, /\\d+/)', TypeError);\r\n```\r\n\r\nAlso, I've updated tests: fixed those that were not in line with latest ES2015 spec (e.g. about iterating over sparse arrays) and added some cases from [Gecko's test suite](https://github.com/mozilla/gecko-dev/blob/5c2f080f015199ee58717612ae931ce0b186adac/js/src/tests/ecma_6/Array/find_findindex.js).\r\n\r\n### Not done\r\nI wasn't sure I'd have time to fix these in my short “sprint”, as each of them deserves its own separate issue. Additionally, some will require adding new language version or a flag.\r\n\r\n- Allow iterating over objects where numeric properties have custom getter, like this:\r\n```js\r\nvar count = 0;\r\nvar a = {get 0() { return count++; }, length: 1};\r\nArray.prototype.find.call(a, (function () { return true; }));\r\n```\r\n- When `thisArg` is not passed, `this` inside predicate should be undefined even in non-strict mode:\r\n```js\r\nvar o = -1;\r\n[1,2].find(function () { o = this; });\r\nassertEquals(undefined, o);\r\n```\r\n- When called with `thisObj` set to `null` or `undefined`, `TypeError` should be thrown:\r\n```js\r\nassertThrows('Array.prototype.find.call(null, function() { })', TypeError);\r\nassertThrows('Array.prototype.find.call(undefined, function() { })', TypeError);\r\nassertThrows('Array.prototype.find.apply(null, function() { }, [])', TypeError);\r\nassertThrows('Array.prototype.find.apply(undefined, function() { }, [])', TypeError);\r\n```\r\nRight now, when `fn.call(null)` is executed, `this` for `fn` is set to global (as per ES3), but in ES2015 `ToObject()` should be called on whatever was passed as `this` and it will throw on `null` and `undefined` values.\r\n\r\n//cc @eshepelyuk","created_at":"2015-04-21T05:03:40Z","updated_at":"2015-06-26T22:31:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6b6db0fc7e46dd401eaf52e94a4215dcf5c7dd1","assignee":null,"milestone":{"url":"https://api.github.com/repos/mozilla/rhino/milestones/2","html_url":"https://github.com/mozilla/rhino/milestones/Release%201.7.8","labels_url":"https://api.github.com/repos/mozilla/rhino/milestones/2/labels","id":1168927,"number":2,"title":"Release 1.7.8","description":"","creator":{"login":"gbrail","id":521323,"avatar_url":"https://avatars.githubusercontent.com/u/521323?v=3","gravatar_id":"","url":"https://api.github.com/users/gbrail","html_url":"https://github.com/gbrail","followers_url":"https://api.github.com/users/gbrail/followers","following_url":"https://api.github.com/users/gbrail/following{/other_user}","gists_url":"https://api.github.com/users/gbrail/gists{/gist_id}","starred_url":"https://api.github.com/users/gbrail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbrail/subscriptions","organizations_url":"https://api.github.com/users/gbrail/orgs","repos_url":"https://api.github.com/users/gbrail/repos","events_url":"https://api.github.com/users/gbrail/events{/privacy}","received_events_url":"https://api.github.com/users/gbrail/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":0,"state":"open","created_at":"2015-06-17T16:32:58Z","updated_at":"2015-06-26T22:31:54Z","due_on":"2015-07-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mozilla/rhino/pulls/174/commits","review_comments_url":"https://api.github.com/repos/mozilla/rhino/pulls/174/comments","review_comment_url":"https://api.github.com/repos/mozilla/rhino/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/rhino/issues/174/comments","statuses_url":"https://api.github.com/repos/mozilla/rhino/statuses/8a8a7ce59286d9e9e462577edec0ebf65c7a542c","head":{"label":"sainaen:array_find","ref":"array_find","sha":"8a8a7ce59286d9e9e462577edec0ebf65c7a542c","user":{"login":"sainaen","id":2400185,"avatar_url":"https://avatars.githubusercontent.com/u/2400185?v=3","gravatar_id":"","url":"https://api.github.com/users/sainaen","html_url":"https://github.com/sainaen","followers_url":"https://api.github.com/users/sainaen/followers","following_url":"https://api.github.com/users/sainaen/following{/other_user}","gists_url":"https://api.github.com/users/sainaen/gists{/gist_id}","starred_url":"https://api.github.com/users/sainaen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sainaen/subscriptions","organizations_url":"https://api.github.com/users/sainaen/orgs","repos_url":"https://api.github.com/users/sainaen/repos","events_url":"https://api.github.com/users/sainaen/events{/privacy}","received_events_url":"https://api.github.com/users/sainaen/received_events","type":"User","site_admin":false},"repo":{"id":21364188,"name":"rhino","full_name":"sainaen/rhino","owner":{"login":"sainaen","id":2400185,"avatar_url":"https://avatars.githubusercontent.com/u/2400185?v=3","gravatar_id":"","url":"https://api.github.com/users/sainaen","html_url":"https://github.com/sainaen","followers_url":"https://api.github.com/users/sainaen/followers","following_url":"https://api.github.com/users/sainaen/following{/other_user}","gists_url":"https://api.github.com/users/sainaen/gists{/gist_id}","starred_url":"https://api.github.com/users/sainaen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sainaen/subscriptions","organizations_url":"https://api.github.com/users/sainaen/orgs","repos_url":"https://api.github.com/users/sainaen/repos","events_url":"https://api.github.com/users/sainaen/events{/privacy}","received_events_url":"https://api.github.com/users/sainaen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sainaen/rhino","description":"Rhino is an open-source implementation of JavaScript written entirely in Java","fork":true,"url":"https://api.github.com/repos/sainaen/rhino","forks_url":"https://api.github.com/repos/sainaen/rhino/forks","keys_url":"https://api.github.com/repos/sainaen/rhino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sainaen/rhino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sainaen/rhino/teams","hooks_url":"https://api.github.com/repos/sainaen/rhino/hooks","issue_events_url":"https://api.github.com/repos/sainaen/rhino/issues/events{/number}","events_url":"https://api.github.com/repos/sainaen/rhino/events","assignees_url":"https://api.github.com/repos/sainaen/rhino/assignees{/user}","branches_url":"https://api.github.com/repos/sainaen/rhino/branches{/branch}","tags_url":"https://api.github.com/repos/sainaen/rhino/tags","blobs_url":"https://api.github.com/repos/sainaen/rhino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sainaen/rhino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sainaen/rhino/git/refs{/sha}","trees_url":"https://api.github.com/repos/sainaen/rhino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sainaen/rhino/statuses/{sha}","languages_url":"https://api.github.com/repos/sainaen/rhino/languages","stargazers_url":"https://api.github.com/repos/sainaen/rhino/stargazers","contributors_url":"https://api.github.com/repos/sainaen/rhino/contributors","subscribers_url":"https://api.github.com/repos/sainaen/rhino/subscribers","subscription_url":"https://api.github.com/repos/sainaen/rhino/subscription","commits_url":"https://api.github.com/repos/sainaen/rhino/commits{/sha}","git_commits_url":"https://api.github.com/repos/sainaen/rhino/git/commits{/sha}","comments_url":"https://api.github.com/repos/sainaen/rhino/comments{/number}","issue_comment_url":"https://api.github.com/repos/sainaen/rhino/issues/comments{/number}","contents_url":"https://api.github.com/repos/sainaen/rhino/contents/{+path}","compare_url":"https://api.github.com/repos/sainaen/rhino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sainaen/rhino/merges","archive_url":"https://api.github.com/repos/sainaen/rhino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sainaen/rhino/downloads","issues_url":"https://api.github.com/repos/sainaen/rhino/issues{/number}","pulls_url":"https://api.github.com/repos/sainaen/rhino/pulls{/number}","milestones_url":"https://api.github.com/repos/sainaen/rhino/milestones{/number}","notifications_url":"https://api.github.com/repos/sainaen/rhino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sainaen/rhino/labels{/name}","releases_url":"https://api.github.com/repos/sainaen/rhino/releases{/id}","created_at":"2014-06-30T20:01:04Z","updated_at":"2015-04-21T05:29:34Z","pushed_at":"2015-05-17T16:45:27Z","git_url":"git://github.com/sainaen/rhino.git","ssh_url":"git@github.com:sainaen/rhino.git","clone_url":"https://github.com/sainaen/rhino.git","svn_url":"https://github.com/sainaen/rhino","homepage":"https://www.mozilla.org/rhino/","size":14603,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"mozilla:master","ref":"master","sha":"fd699d1d991346b16b4d0dda26663dbe13abe08e","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":1739767,"name":"rhino","full_name":"mozilla/rhino","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/rhino","description":"Rhino is an open-source implementation of JavaScript written entirely in Java","fork":false,"url":"https://api.github.com/repos/mozilla/rhino","forks_url":"https://api.github.com/repos/mozilla/rhino/forks","keys_url":"https://api.github.com/repos/mozilla/rhino/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/rhino/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/rhino/teams","hooks_url":"https://api.github.com/repos/mozilla/rhino/hooks","issue_events_url":"https://api.github.com/repos/mozilla/rhino/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/rhino/events","assignees_url":"https://api.github.com/repos/mozilla/rhino/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/rhino/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/rhino/tags","blobs_url":"https://api.github.com/repos/mozilla/rhino/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/rhino/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/rhino/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/rhino/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/rhino/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/rhino/languages","stargazers_url":"https://api.github.com/repos/mozilla/rhino/stargazers","contributors_url":"https://api.github.com/repos/mozilla/rhino/contributors","subscribers_url":"https://api.github.com/repos/mozilla/rhino/subscribers","subscription_url":"https://api.github.com/repos/mozilla/rhino/subscription","commits_url":"https://api.github.com/repos/mozilla/rhino/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/rhino/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/rhino/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/rhino/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/rhino/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/rhino/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/rhino/merges","archive_url":"https://api.github.com/repos/mozilla/rhino/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/rhino/downloads","issues_url":"https://api.github.com/repos/mozilla/rhino/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/rhino/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/rhino/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/rhino/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/rhino/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/rhino/releases{/id}","created_at":"2011-05-12T18:47:26Z","updated_at":"2015-06-26T14:59:00Z","pushed_at":"2015-06-26T22:03:09Z","git_url":"git://github.com/mozilla/rhino.git","ssh_url":"git@github.com:mozilla/rhino.git","clone_url":"https://github.com/mozilla/rhino.git","svn_url":"https://github.com/mozilla/rhino","homepage":"https://www.mozilla.org/rhino/","size":22543,"stargazers_count":833,"watchers_count":833,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":280,"mirror_url":null,"open_issues_count":67,"forks":280,"open_issues":67,"watchers":833,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/rhino/pulls/174"},"html":{"href":"https://github.com/mozilla/rhino/pull/174"},"issue":{"href":"https://api.github.com/repos/mozilla/rhino/issues/174"},"comments":{"href":"https://api.github.com/repos/mozilla/rhino/issues/174/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/rhino/pulls/174/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/rhino/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/rhino/pulls/174/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/rhino/statuses/8a8a7ce59286d9e9e462577edec0ebf65c7a542c"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":18,"review_comments":0,"commits":4,"additions":436,"deletions":253,"changed_files":3}}