{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments/86715728","pull_request_review_id":7351581,"id":86715728,"diff_hunk":"@@ -6,65 +6,136 @@\n  */\n exports.isStar = true;\n \n-/**\n- * Запрос к коллекции\n- * @param {Array} collection\n- * @params {...Function} – Функции для запроса\n- * @returns {Array}\n- */\n+var PRIOPITY_FUNC = ['format', 'limit', 'select', 'sortBy', 'or', 'and', 'filterIn'];\n+\n exports.query = function (collection) {\n-    return collection;\n+    var masFriends = collection.map(function (elementMas) {\n+\n+        return Object.assign({}, elementMas);\n+    });\n+    var keyFunc = [].slice.call(arguments, 1);\n+    keyFunc.sort(sortFunc);\n+    keyFunc.forEach(function (item) {\n+        masFriends = item(masFriends);\n+    });\n+\n+    return masFriends;\n };\n \n+function sortFunc(el1, el2) {\n+\n+    return PRIOPITY_FUNC.indexOf(el1.name) < PRIOPITY_FUNC.indexOf(el2.name);\n+}\n+\n /**\n  * Выбор полей\n  * @params {...String}\n+ * @returns {Array}\n  */\n exports.select = function () {\n-    return;\n+    var field = [].slice.call(arguments);\n+\n+    return function select(masFriends) {\n+        var newMasFriends = masFriends.slice();\n+        newMasFriends.reduce(function (previousValue, currentValeu) {\n+            var masKey = Object.keys(currentValeu);\n+            masKey.forEach(function (item) {\n+                if (field.indexOf(item) === -1) {\n+                    delete currentValeu[item];\n+                }\n+            });\n+\n+            return '';\n+        }, 0);","path":"lego.js","position":52,"original_position":52,"commit_id":"4e1874ea3a7f4027b96d133cd580875111a2015c","original_commit_id":"4e1874ea3a7f4027b96d133cd580875111a2015c","user":{"login":"dzlk","id":894822,"avatar_url":"https://avatars.githubusercontent.com/u/894822?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlk","html_url":"https://github.com/dzlk","followers_url":"https://api.github.com/users/dzlk/followers","following_url":"https://api.github.com/users/dzlk/following{/other_user}","gists_url":"https://api.github.com/users/dzlk/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlk/subscriptions","organizations_url":"https://api.github.com/users/dzlk/orgs","repos_url":"https://api.github.com/users/dzlk/repos","events_url":"https://api.github.com/users/dzlk/events{/privacy}","received_events_url":"https://api.github.com/users/dzlk/received_events","type":"User","site_admin":false},"body":"❗️ Очень странный reduce. Почему ноль аккумелятор, а посел возвращается пустая строка?\r\nДля чего нужен previousValue?\r\nПредлагаю переписать. Так как тебе нужно операцию селект выполнить на каждым элементом коллекции и вернуть новый, а размерность входного и выходного массивов одинаковая, значит нужно использовать map. Так как у нас есть набор полей которые надо превратить в объект, то тут подойдет reduce по полям (fields) и копированием полей из текущего элемента\r\nПримерно так\r\n```\r\nreturn collection.map(function (item) {\r\n  retutn fields.reduce(function (newItem, field) {  ... }, {});\r\n})\r\n``` ","created_at":"2016-11-07T05:41:46Z","updated_at":"2016-11-07T05:49:20Z","html_url":"https://github.com/urfu-2016/javascript-task-4/pull/30#discussion_r86715728","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments/86715728"},"html":{"href":"https://github.com/urfu-2016/javascript-task-4/pull/30#discussion_r86715728"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30","id":91834125,"html_url":"https://github.com/urfu-2016/javascript-task-4/pull/30","diff_url":"https://github.com/urfu-2016/javascript-task-4/pull/30.diff","patch_url":"https://github.com/urfu-2016/javascript-task-4/pull/30.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/30","number":30,"state":"open","locked":false,"title":"Ганиева Альбина","user":{"login":"Albina-G","id":22474086,"avatar_url":"https://avatars.githubusercontent.com/u/22474086?v=3","gravatar_id":"","url":"https://api.github.com/users/Albina-G","html_url":"https://github.com/Albina-G","followers_url":"https://api.github.com/users/Albina-G/followers","following_url":"https://api.github.com/users/Albina-G/following{/other_user}","gists_url":"https://api.github.com/users/Albina-G/gists{/gist_id}","starred_url":"https://api.github.com/users/Albina-G/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Albina-G/subscriptions","organizations_url":"https://api.github.com/users/Albina-G/orgs","repos_url":"https://api.github.com/users/Albina-G/repos","events_url":"https://api.github.com/users/Albina-G/events{/privacy}","received_events_url":"https://api.github.com/users/Albina-G/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-01T18:09:41Z","updated_at":"2016-11-07T05:49:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7222fa633a0847c63290dc49b9afc9254de8b682","assignee":{"login":"dzlk","id":894822,"avatar_url":"https://avatars.githubusercontent.com/u/894822?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlk","html_url":"https://github.com/dzlk","followers_url":"https://api.github.com/users/dzlk/followers","following_url":"https://api.github.com/users/dzlk/following{/other_user}","gists_url":"https://api.github.com/users/dzlk/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlk/subscriptions","organizations_url":"https://api.github.com/users/dzlk/orgs","repos_url":"https://api.github.com/users/dzlk/repos","events_url":"https://api.github.com/users/dzlk/events{/privacy}","received_events_url":"https://api.github.com/users/dzlk/received_events","type":"User","site_admin":false},"assignees":[{"login":"dzlk","id":894822,"avatar_url":"https://avatars.githubusercontent.com/u/894822?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlk","html_url":"https://github.com/dzlk","followers_url":"https://api.github.com/users/dzlk/followers","following_url":"https://api.github.com/users/dzlk/following{/other_user}","gists_url":"https://api.github.com/users/dzlk/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlk/subscriptions","organizations_url":"https://api.github.com/users/dzlk/orgs","repos_url":"https://api.github.com/users/dzlk/repos","events_url":"https://api.github.com/users/dzlk/events{/privacy}","received_events_url":"https://api.github.com/users/dzlk/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30/comments","review_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/30/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/statuses/4e1874ea3a7f4027b96d133cd580875111a2015c","head":{"label":"Albina-G:master","ref":"master","sha":"4e1874ea3a7f4027b96d133cd580875111a2015c","user":{"login":"Albina-G","id":22474086,"avatar_url":"https://avatars.githubusercontent.com/u/22474086?v=3","gravatar_id":"","url":"https://api.github.com/users/Albina-G","html_url":"https://github.com/Albina-G","followers_url":"https://api.github.com/users/Albina-G/followers","following_url":"https://api.github.com/users/Albina-G/following{/other_user}","gists_url":"https://api.github.com/users/Albina-G/gists{/gist_id}","starred_url":"https://api.github.com/users/Albina-G/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Albina-G/subscriptions","organizations_url":"https://api.github.com/users/Albina-G/orgs","repos_url":"https://api.github.com/users/Albina-G/repos","events_url":"https://api.github.com/users/Albina-G/events{/privacy}","received_events_url":"https://api.github.com/users/Albina-G/received_events","type":"User","site_admin":false},"repo":{"id":72337401,"name":"javascript-task-4","full_name":"Albina-G/javascript-task-4","owner":{"login":"Albina-G","id":22474086,"avatar_url":"https://avatars.githubusercontent.com/u/22474086?v=3","gravatar_id":"","url":"https://api.github.com/users/Albina-G","html_url":"https://github.com/Albina-G","followers_url":"https://api.github.com/users/Albina-G/followers","following_url":"https://api.github.com/users/Albina-G/following{/other_user}","gists_url":"https://api.github.com/users/Albina-G/gists{/gist_id}","starred_url":"https://api.github.com/users/Albina-G/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Albina-G/subscriptions","organizations_url":"https://api.github.com/users/Albina-G/orgs","repos_url":"https://api.github.com/users/Albina-G/repos","events_url":"https://api.github.com/users/Albina-G/events{/privacy}","received_events_url":"https://api.github.com/users/Albina-G/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Albina-G/javascript-task-4","description":"Задача «Картофельная вечеринка Билли»","fork":true,"url":"https://api.github.com/repos/Albina-G/javascript-task-4","forks_url":"https://api.github.com/repos/Albina-G/javascript-task-4/forks","keys_url":"https://api.github.com/repos/Albina-G/javascript-task-4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Albina-G/javascript-task-4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Albina-G/javascript-task-4/teams","hooks_url":"https://api.github.com/repos/Albina-G/javascript-task-4/hooks","issue_events_url":"https://api.github.com/repos/Albina-G/javascript-task-4/issues/events{/number}","events_url":"https://api.github.com/repos/Albina-G/javascript-task-4/events","assignees_url":"https://api.github.com/repos/Albina-G/javascript-task-4/assignees{/user}","branches_url":"https://api.github.com/repos/Albina-G/javascript-task-4/branches{/branch}","tags_url":"https://api.github.com/repos/Albina-G/javascript-task-4/tags","blobs_url":"https://api.github.com/repos/Albina-G/javascript-task-4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Albina-G/javascript-task-4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Albina-G/javascript-task-4/git/refs{/sha}","trees_url":"https://api.github.com/repos/Albina-G/javascript-task-4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Albina-G/javascript-task-4/statuses/{sha}","languages_url":"https://api.github.com/repos/Albina-G/javascript-task-4/languages","stargazers_url":"https://api.github.com/repos/Albina-G/javascript-task-4/stargazers","contributors_url":"https://api.github.com/repos/Albina-G/javascript-task-4/contributors","subscribers_url":"https://api.github.com/repos/Albina-G/javascript-task-4/subscribers","subscription_url":"https://api.github.com/repos/Albina-G/javascript-task-4/subscription","commits_url":"https://api.github.com/repos/Albina-G/javascript-task-4/commits{/sha}","git_commits_url":"https://api.github.com/repos/Albina-G/javascript-task-4/git/commits{/sha}","comments_url":"https://api.github.com/repos/Albina-G/javascript-task-4/comments{/number}","issue_comment_url":"https://api.github.com/repos/Albina-G/javascript-task-4/issues/comments{/number}","contents_url":"https://api.github.com/repos/Albina-G/javascript-task-4/contents/{+path}","compare_url":"https://api.github.com/repos/Albina-G/javascript-task-4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Albina-G/javascript-task-4/merges","archive_url":"https://api.github.com/repos/Albina-G/javascript-task-4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Albina-G/javascript-task-4/downloads","issues_url":"https://api.github.com/repos/Albina-G/javascript-task-4/issues{/number}","pulls_url":"https://api.github.com/repos/Albina-G/javascript-task-4/pulls{/number}","milestones_url":"https://api.github.com/repos/Albina-G/javascript-task-4/milestones{/number}","notifications_url":"https://api.github.com/repos/Albina-G/javascript-task-4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Albina-G/javascript-task-4/labels{/name}","releases_url":"https://api.github.com/repos/Albina-G/javascript-task-4/releases{/id}","deployments_url":"https://api.github.com/repos/Albina-G/javascript-task-4/deployments","created_at":"2016-10-30T08:18:05Z","updated_at":"2016-10-30T08:18:06Z","pushed_at":"2016-11-06T12:51:17Z","git_url":"git://github.com/Albina-G/javascript-task-4.git","ssh_url":"git@github.com:Albina-G/javascript-task-4.git","clone_url":"https://github.com/Albina-G/javascript-task-4.git","svn_url":"https://github.com/Albina-G/javascript-task-4","homepage":"","size":12,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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-2016:master","ref":"master","sha":"7478a115049e4e20247defea7e2f8dc6f49a8239","user":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":71762351,"name":"javascript-task-4","full_name":"urfu-2016/javascript-task-4","owner":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2016/javascript-task-4","description":"Задача «Картофельная вечеринка Билли»","fork":false,"url":"https://api.github.com/repos/urfu-2016/javascript-task-4","forks_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/forks","keys_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/teams","hooks_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/hooks","issue_events_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/events","assignees_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/tags","blobs_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/languages","stargazers_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/stargazers","contributors_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/contributors","subscribers_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/subscribers","subscription_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/subscription","commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/merges","archive_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/downloads","issues_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/deployments","created_at":"2016-10-24T07:19:05Z","updated_at":"2016-10-27T17:04:42Z","pushed_at":"2016-11-07T05:32:44Z","git_url":"git://github.com/urfu-2016/javascript-task-4.git","ssh_url":"git@github.com:urfu-2016/javascript-task-4.git","clone_url":"https://github.com/urfu-2016/javascript-task-4.git","svn_url":"https://github.com/urfu-2016/javascript-task-4","homepage":"","size":13,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":82,"mirror_url":null,"open_issues_count":53,"forks":82,"open_issues":53,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30"},"html":{"href":"https://github.com/urfu-2016/javascript-task-4/pull/30"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/30"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/statuses/4e1874ea3a7f4027b96d133cd580875111a2015c"}}}}
{"actor":{"display_login":"dzlk"}}