{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments/86717382","pull_request_review_id":7359734,"id":86717382,"diff_hunk":"@@ -4,67 +4,132 @@\n  * Сделано задание на звездочку\n  * Реализованы методы or и and\n  */\n-exports.isStar = true;\n+exports.isStar = false;\n+var FUNCTIONS_PRIORITY = {\n+    'filterIn': 1,\n+    'sortBy': 2,\n+    'select': 3,\n+    'limit': 4,\n+    'format': 5\n+};\n \n /**\n  * Запрос к коллекции\n  * @param {Array} collection\n  * @params {...Function} – Функции для запроса\n  * @returns {Array}\n+ * @returns {Array}\n  */\n exports.query = function (collection) {\n-    return collection;\n+    var collectionCopy = JSON.parse(JSON.stringify(collection));\n+    var functions = [].slice.call(arguments, 1).sort(function (firstFunc, secondFunc) {\n+        return FUNCTIONS_PRIORITY[firstFunc.name] < FUNCTIONS_PRIORITY[secondFunc.name] ? -1 : 1;\n+    });\n+    collectionCopy = functions.reduce(function (a, func) {\n+        return func(a);\n+    }, collectionCopy);\n+\n+    return collectionCopy;\n };\n \n /**\n  * Выбор полей\n  * @params {...String}\n+ * @returns {Function}\n  */\n exports.select = function () {\n-    return;\n+    var selectedKeys = [].slice.call(arguments);\n+\n+    return function select(collection) {\n+        var newCollection = [];\n+        collection.forEach(function (record) {\n+            newCollection.push(selectRecord(record, selectedKeys));\n+        });\n+\n+        return newCollection;\n+    };\n };\n \n+function selectRecord(record, selectedKeys) {\n+    var selectedRecord = {};\n+    for (var key in record) {\n+        if (selectedKeys.indexOf(key) !== -1) {\n+            selectedRecord[key] = record[key];\n+        }\n+    }\n+\n+    return selectedRecord;\n+}\n+\n /**\n  * Фильтрация поля по массиву значений\n  * @param {String} property – Свойство для фильтрации\n  * @param {Array} values – Доступные значения\n+ * @returns {Function}\n  */\n exports.filterIn = function (property, values) {\n-    console.info(property, values);\n+    return function filterIn(collection) {\n+        var newCollection = [];\n+        collection.forEach(function (record) {\n+            if (isRecordContainsProperty(record, property, values)) {\n+                newCollection.push(record);\n+            }\n+        });\n \n-    return;\n+        return newCollection;\n+    };\n };\n \n+function isRecordContainsProperty(record, property, values) {\n+    return record.hasOwnProperty(property) && (values.indexOf(record[property]) !== -1);","path":"lego.js","position":86,"original_position":86,"commit_id":"c46a2c9f6ccbed317f4ba580d5b5cf6d706e7686","original_commit_id":"c46a2c9f6ccbed317f4ba580d5b5cf6d706e7686","user":{"login":"gogoleff","id":4534405,"avatar_url":"https://avatars.githubusercontent.com/u/4534405?v=3","gravatar_id":"","url":"https://api.github.com/users/gogoleff","html_url":"https://github.com/gogoleff","followers_url":"https://api.github.com/users/gogoleff/followers","following_url":"https://api.github.com/users/gogoleff/following{/other_user}","gists_url":"https://api.github.com/users/gogoleff/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoleff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoleff/subscriptions","organizations_url":"https://api.github.com/users/gogoleff/orgs","repos_url":"https://api.github.com/users/gogoleff/repos","events_url":"https://api.github.com/users/gogoleff/events{/privacy}","received_events_url":"https://api.github.com/users/gogoleff/received_events","type":"User","site_admin":false},"body":"Во вторых круглых скобках нет необходимости","created_at":"2016-11-07T06:07:24Z","updated_at":"2016-11-07T06:17:56Z","html_url":"https://github.com/urfu-2016/javascript-task-4/pull/58#discussion_r86717382","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/comments/86717382"},"html":{"href":"https://github.com/urfu-2016/javascript-task-4/pull/58#discussion_r86717382"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58","id":92021498,"html_url":"https://github.com/urfu-2016/javascript-task-4/pull/58","diff_url":"https://github.com/urfu-2016/javascript-task-4/pull/58.diff","patch_url":"https://github.com/urfu-2016/javascript-task-4/pull/58.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/58","number":58,"state":"open","locked":false,"title":"Шмонина Ирина","user":{"login":"IrinaShmonina","id":19413034,"avatar_url":"https://avatars.githubusercontent.com/u/19413034?v=3","gravatar_id":"","url":"https://api.github.com/users/IrinaShmonina","html_url":"https://github.com/IrinaShmonina","followers_url":"https://api.github.com/users/IrinaShmonina/followers","following_url":"https://api.github.com/users/IrinaShmonina/following{/other_user}","gists_url":"https://api.github.com/users/IrinaShmonina/gists{/gist_id}","starred_url":"https://api.github.com/users/IrinaShmonina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IrinaShmonina/subscriptions","organizations_url":"https://api.github.com/users/IrinaShmonina/orgs","repos_url":"https://api.github.com/users/IrinaShmonina/repos","events_url":"https://api.github.com/users/IrinaShmonina/events{/privacy}","received_events_url":"https://api.github.com/users/IrinaShmonina/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-02T17:48:02Z","updated_at":"2016-11-07T06:17:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8f39935d09123d2554451e0c6df39b80acc54d9","assignee":{"login":"gogoleff","id":4534405,"avatar_url":"https://avatars.githubusercontent.com/u/4534405?v=3","gravatar_id":"","url":"https://api.github.com/users/gogoleff","html_url":"https://github.com/gogoleff","followers_url":"https://api.github.com/users/gogoleff/followers","following_url":"https://api.github.com/users/gogoleff/following{/other_user}","gists_url":"https://api.github.com/users/gogoleff/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoleff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoleff/subscriptions","organizations_url":"https://api.github.com/users/gogoleff/orgs","repos_url":"https://api.github.com/users/gogoleff/repos","events_url":"https://api.github.com/users/gogoleff/events{/privacy}","received_events_url":"https://api.github.com/users/gogoleff/received_events","type":"User","site_admin":false},"assignees":[{"login":"gogoleff","id":4534405,"avatar_url":"https://avatars.githubusercontent.com/u/4534405?v=3","gravatar_id":"","url":"https://api.github.com/users/gogoleff","html_url":"https://github.com/gogoleff","followers_url":"https://api.github.com/users/gogoleff/followers","following_url":"https://api.github.com/users/gogoleff/following{/other_user}","gists_url":"https://api.github.com/users/gogoleff/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoleff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoleff/subscriptions","organizations_url":"https://api.github.com/users/gogoleff/orgs","repos_url":"https://api.github.com/users/gogoleff/repos","events_url":"https://api.github.com/users/gogoleff/events{/privacy}","received_events_url":"https://api.github.com/users/gogoleff/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58/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/58/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-4/statuses/c46a2c9f6ccbed317f4ba580d5b5cf6d706e7686","head":{"label":"IrinaShmonina:master","ref":"master","sha":"c46a2c9f6ccbed317f4ba580d5b5cf6d706e7686","user":{"login":"IrinaShmonina","id":19413034,"avatar_url":"https://avatars.githubusercontent.com/u/19413034?v=3","gravatar_id":"","url":"https://api.github.com/users/IrinaShmonina","html_url":"https://github.com/IrinaShmonina","followers_url":"https://api.github.com/users/IrinaShmonina/followers","following_url":"https://api.github.com/users/IrinaShmonina/following{/other_user}","gists_url":"https://api.github.com/users/IrinaShmonina/gists{/gist_id}","starred_url":"https://api.github.com/users/IrinaShmonina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IrinaShmonina/subscriptions","organizations_url":"https://api.github.com/users/IrinaShmonina/orgs","repos_url":"https://api.github.com/users/IrinaShmonina/repos","events_url":"https://api.github.com/users/IrinaShmonina/events{/privacy}","received_events_url":"https://api.github.com/users/IrinaShmonina/received_events","type":"User","site_admin":false},"repo":{"id":72553840,"name":"javascript-task-4","full_name":"IrinaShmonina/javascript-task-4","owner":{"login":"IrinaShmonina","id":19413034,"avatar_url":"https://avatars.githubusercontent.com/u/19413034?v=3","gravatar_id":"","url":"https://api.github.com/users/IrinaShmonina","html_url":"https://github.com/IrinaShmonina","followers_url":"https://api.github.com/users/IrinaShmonina/followers","following_url":"https://api.github.com/users/IrinaShmonina/following{/other_user}","gists_url":"https://api.github.com/users/IrinaShmonina/gists{/gist_id}","starred_url":"https://api.github.com/users/IrinaShmonina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IrinaShmonina/subscriptions","organizations_url":"https://api.github.com/users/IrinaShmonina/orgs","repos_url":"https://api.github.com/users/IrinaShmonina/repos","events_url":"https://api.github.com/users/IrinaShmonina/events{/privacy}","received_events_url":"https://api.github.com/users/IrinaShmonina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IrinaShmonina/javascript-task-4","description":"Задача «Картофельная вечеринка Билли»","fork":true,"url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4","forks_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/forks","keys_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/teams","hooks_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/hooks","issue_events_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/issues/events{/number}","events_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/events","assignees_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/assignees{/user}","branches_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/branches{/branch}","tags_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/tags","blobs_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/git/refs{/sha}","trees_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/statuses/{sha}","languages_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/languages","stargazers_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/stargazers","contributors_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/contributors","subscribers_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/subscribers","subscription_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/subscription","commits_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/commits{/sha}","git_commits_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/git/commits{/sha}","comments_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/comments{/number}","issue_comment_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/issues/comments{/number}","contents_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/contents/{+path}","compare_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/merges","archive_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/downloads","issues_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/issues{/number}","pulls_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/pulls{/number}","milestones_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/milestones{/number}","notifications_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/labels{/name}","releases_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/releases{/id}","deployments_url":"https://api.github.com/repos/IrinaShmonina/javascript-task-4/deployments","created_at":"2016-11-01T16:17:13Z","updated_at":"2016-11-01T16:17:14Z","pushed_at":"2016-11-06T14:25:12Z","git_url":"git://github.com/IrinaShmonina/javascript-task-4.git","ssh_url":"git@github.com:IrinaShmonina/javascript-task-4.git","clone_url":"https://github.com/IrinaShmonina/javascript-task-4.git","svn_url":"https://github.com/IrinaShmonina/javascript-task-4","homepage":"","size":8,"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/58"},"html":{"href":"https://github.com/urfu-2016/javascript-task-4/pull/58"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/58"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/pulls/58/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/58/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-4/statuses/c46a2c9f6ccbed317f4ba580d5b5cf6d706e7686"}}}}
{"actor":{"display_login":"gogoleff"}}