{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/comments/43583032","id":43583032,"diff_hunk":"@@ -1,4 +1,147 @@\n 'use strict';\n \n module.exports.get = function (collection, startPoint, depth) {\n+    return new Iterator(collection, startPoint, depth);\n+};\n+\n+function Iterator(collection, startPoint, depth) {\n+    var curent = 0;\n+\n+    depth = Number.isInteger(depth) ? depth : 0;\n+\n+    if (typeof startPoint === undefined || !collection.hasOwnProperty(startPoint)) {\n+        curent = NaN;\n+    } else {\n+        var listNames = createListNames(startPoint);\n+    }\n+\n+    function createListNames(name) {\n+        var curentDepth = -1;\n+        var following = [];\n+        var curents = [name];\n+        var result = [];\n+\n+        putNamesInResult();\n+        return result;\n+\n+        function putNamesInResult() {\n+            for (var name of curents) {\n+                result.push(name);\n+                following = following.concat(getFriends(name));\n+            }\n+            if (following.length === 0) {\n+                return;\n+            }\n+\n+            curents = following.sort();\n+            following = [];\n+            curentDepth ++;\n+\n+            if (depth - curentDepth !== 0 || depth === 0) {\n+                putNamesInResult();\n+            }\n+        }\n+\n+        function getFriends(name) {\n+            var friends = [];\n+            for (var friend of collection[name]['friends']) {\n+                if (curents.indexOf(friend) === -1 &&\n+                    following.indexOf(friend) === -1 &&\n+                    result.indexOf(friend) === -1 &&\n+                    collection.hasOwnProperty(friend)) {\n+                    friends.push(friend);\n+                }\n+            }\n+            return friends;\n+        }\n+    }\n+\n+    this.next = function () {\n+        if (isNaN(curent)) {\n+            return null;\n+        }\n+        isChange() || rebuild();\n+\n+        if (arguments.length > 0) {\n+            var indexElement = listNames.indexOf(arguments[0]);\n+            if (indexElement === -1) {\n+                curent = listNames.length;\n+                return null;\n+            }\n+            curent = indexElement;\n+            return collectEntry(listNames[indexElement]);\n+        }\n+\n+        curent ++;\n+        if (curent >= listNames.length) {\n+            curent = listNames.length;\n+            return null;\n+        }\n+\n+        return collectEntry(listNames[curent]);\n+    };\n+\n+    this.prev = function () {\n+        if (isNaN(curent)) {\n+            return null;\n+        }\n+        isChange() || rebuild();\n+\n+        curent --;\n+        if (curent < 0) {\n+            curent = -1;\n+            return null;\n+        }\n+\n+        return collectEntry(listNames[curent]);\n+    };\n+\n+    this.nextMale = function () {\n+        if (isNaN(curent)) {\n+            return null;\n+        }\n+        isChange() || rebuild();\n+\n+        for (var i = curent + 1; i < listNames.length; i++) {\n+            if (collection[listNames[i]]['gender'] === 'Мужской') {\n+                curent = i;\n+                return collectEntry(listNames[i]);\n+            }\n+        };\n+        curent = listNames.length;\n+        return null;\n+    };\n+\n+    this.prevMale = function () {\n+        if (isNaN(curent)) {\n+            return null;\n+        }\n+        isChange() || rebuild();\n+\n+        for (var i = curent - 1; i > -1; i--) {\n+            if (collection[listNames[i]]['gender'] === 'Мужской') {\n+                curent = i;\n+                return collectEntry(listNames[i]);\n+            }\n+        };\n+\n+        curent = -1;\n+        return null;\n+    };\n+\n+    function isChange() {\n+        return listNames.every(item => {\n+            return collection.hasOwnProperty(item);","path":"iterator.js","position":134,"original_position":134,"commit_id":"8d23e89b7b64e7815f6f4de68e1868ad550a7e3a","original_commit_id":"8d23e89b7b64e7815f6f4de68e1868ad550a7e3a","user":{"login":"sorovlad","id":14935625,"avatar_url":"https://avatars.githubusercontent.com/u/14935625?v=3","gravatar_id":"","url":"https://api.github.com/users/sorovlad","html_url":"https://github.com/sorovlad","followers_url":"https://api.github.com/users/sorovlad/followers","following_url":"https://api.github.com/users/sorovlad/following{/other_user}","gists_url":"https://api.github.com/users/sorovlad/gists{/gist_id}","starred_url":"https://api.github.com/users/sorovlad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorovlad/subscriptions","organizations_url":"https://api.github.com/users/sorovlad/orgs","repos_url":"https://api.github.com/users/sorovlad/repos","events_url":"https://api.github.com/users/sorovlad/events{/privacy}","received_events_url":"https://api.github.com/users/sorovlad/received_events","type":"User","site_admin":false},"body":"проигнорирует. в условии задачи не сказано про добавление. нужно?","created_at":"2015-11-01T14:19:39Z","updated_at":"2015-11-01T14:19:39Z","html_url":"https://github.com/urfu-2015/javascript-tasks-4/pull/12#discussion_r43583032","pull_request_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/comments/43583032"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-4/pull/12#discussion_r43583032"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12","id":48658274,"html_url":"https://github.com/urfu-2015/javascript-tasks-4/pull/12","diff_url":"https://github.com/urfu-2015/javascript-tasks-4/pull/12.diff","patch_url":"https://github.com/urfu-2015/javascript-tasks-4/pull/12.patch","issue_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/12","number":12,"state":"open","locked":false,"title":"Сорокин Владимир","user":{"login":"sorovlad","id":14935625,"avatar_url":"https://avatars.githubusercontent.com/u/14935625?v=3","gravatar_id":"","url":"https://api.github.com/users/sorovlad","html_url":"https://github.com/sorovlad","followers_url":"https://api.github.com/users/sorovlad/followers","following_url":"https://api.github.com/users/sorovlad/following{/other_user}","gists_url":"https://api.github.com/users/sorovlad/gists{/gist_id}","starred_url":"https://api.github.com/users/sorovlad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorovlad/subscriptions","organizations_url":"https://api.github.com/users/sorovlad/orgs","repos_url":"https://api.github.com/users/sorovlad/repos","events_url":"https://api.github.com/users/sorovlad/events{/privacy}","received_events_url":"https://api.github.com/users/sorovlad/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-24T15:37:07Z","updated_at":"2015-11-01T14:19:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9779f3196bed2330d5158b09777ac2f11dbf364f","assignee":{"login":"mangin","id":7918881,"avatar_url":"https://avatars.githubusercontent.com/u/7918881?v=3","gravatar_id":"","url":"https://api.github.com/users/mangin","html_url":"https://github.com/mangin","followers_url":"https://api.github.com/users/mangin/followers","following_url":"https://api.github.com/users/mangin/following{/other_user}","gists_url":"https://api.github.com/users/mangin/gists{/gist_id}","starred_url":"https://api.github.com/users/mangin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mangin/subscriptions","organizations_url":"https://api.github.com/users/mangin/orgs","repos_url":"https://api.github.com/users/mangin/repos","events_url":"https://api.github.com/users/mangin/events{/privacy}","received_events_url":"https://api.github.com/users/mangin/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/12/comments","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/statuses/8d23e89b7b64e7815f6f4de68e1868ad550a7e3a","head":{"label":"sorovlad:master","ref":"master","sha":"8d23e89b7b64e7815f6f4de68e1868ad550a7e3a","user":{"login":"sorovlad","id":14935625,"avatar_url":"https://avatars.githubusercontent.com/u/14935625?v=3","gravatar_id":"","url":"https://api.github.com/users/sorovlad","html_url":"https://github.com/sorovlad","followers_url":"https://api.github.com/users/sorovlad/followers","following_url":"https://api.github.com/users/sorovlad/following{/other_user}","gists_url":"https://api.github.com/users/sorovlad/gists{/gist_id}","starred_url":"https://api.github.com/users/sorovlad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorovlad/subscriptions","organizations_url":"https://api.github.com/users/sorovlad/orgs","repos_url":"https://api.github.com/users/sorovlad/repos","events_url":"https://api.github.com/users/sorovlad/events{/privacy}","received_events_url":"https://api.github.com/users/sorovlad/received_events","type":"User","site_admin":false},"repo":{"id":44818739,"name":"javascript-tasks-4","full_name":"sorovlad/javascript-tasks-4","owner":{"login":"sorovlad","id":14935625,"avatar_url":"https://avatars.githubusercontent.com/u/14935625?v=3","gravatar_id":"","url":"https://api.github.com/users/sorovlad","html_url":"https://github.com/sorovlad","followers_url":"https://api.github.com/users/sorovlad/followers","following_url":"https://api.github.com/users/sorovlad/following{/other_user}","gists_url":"https://api.github.com/users/sorovlad/gists{/gist_id}","starred_url":"https://api.github.com/users/sorovlad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorovlad/subscriptions","organizations_url":"https://api.github.com/users/sorovlad/orgs","repos_url":"https://api.github.com/users/sorovlad/repos","events_url":"https://api.github.com/users/sorovlad/events{/privacy}","received_events_url":"https://api.github.com/users/sorovlad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sorovlad/javascript-tasks-4","description":"Задача к лекции «Замыкания в Javascript» – «Мальчишник в Вегасе»","fork":true,"url":"https://api.github.com/repos/sorovlad/javascript-tasks-4","forks_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/forks","keys_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/teams","hooks_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/hooks","issue_events_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/issues/events{/number}","events_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/events","assignees_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/assignees{/user}","branches_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/branches{/branch}","tags_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/tags","blobs_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/git/refs{/sha}","trees_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/statuses/{sha}","languages_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/languages","stargazers_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/stargazers","contributors_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/contributors","subscribers_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/subscribers","subscription_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/subscription","commits_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/commits{/sha}","git_commits_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/git/commits{/sha}","comments_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/comments{/number}","issue_comment_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/issues/comments{/number}","contents_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/contents/{+path}","compare_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/merges","archive_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/downloads","issues_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/issues{/number}","pulls_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/pulls{/number}","milestones_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/milestones{/number}","notifications_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/labels{/name}","releases_url":"https://api.github.com/repos/sorovlad/javascript-tasks-4/releases{/id}","created_at":"2015-10-23T14:38:51Z","updated_at":"2015-10-23T14:38:52Z","pushed_at":"2015-10-29T20:02:50Z","git_url":"git://github.com/sorovlad/javascript-tasks-4.git","ssh_url":"git@github.com:sorovlad/javascript-tasks-4.git","clone_url":"https://github.com/sorovlad/javascript-tasks-4.git","svn_url":"https://github.com/sorovlad/javascript-tasks-4","homepage":"","size":139,"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":"urfu-2015:master","ref":"master","sha":"6125978146eec1796f87a724228d8278a4aa66f6","user":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":44542271,"name":"javascript-tasks-4","full_name":"urfu-2015/javascript-tasks-4","owner":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2015/javascript-tasks-4","description":"Задача к лекции «Замыкания в Javascript» – «Мальчишник в Вегасе»","fork":false,"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4","forks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/forks","keys_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/teams","hooks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/events","assignees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/tags","blobs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/subscription","commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/merges","archive_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/downloads","issues_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/releases{/id}","created_at":"2015-10-19T14:57:11Z","updated_at":"2015-10-20T18:57:43Z","pushed_at":"2015-11-01T13:51:54Z","git_url":"git://github.com/urfu-2015/javascript-tasks-4.git","ssh_url":"git@github.com:urfu-2015/javascript-tasks-4.git","clone_url":"https://github.com/urfu-2015/javascript-tasks-4.git","svn_url":"https://github.com/urfu-2015/javascript-tasks-4","homepage":"","size":1531,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":39,"forks":63,"open_issues":39,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-4/pull/12"},"issue":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/12"},"comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-4/statuses/8d23e89b7b64e7815f6f4de68e1868ad550a7e3a"}}}}