{"action":"created","comment":{"url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/comments/176289367","pull_request_review_id":105965023,"id":176289367,"diff_hunk":"@@ -5,6 +5,39 @@ const utqueue = require('ut-queue');\n const portStreams = require('./pull');\n const timing = require('./timing');\n \n+const codecFlow = {\n+    encode: [['beforeEncode'], ['codec', 'encode'], ['afterEncode']],\n+    decode: [['beforeDecode'], ['codec', 'decode'], ['afterDecode']]\n+};\n+\n+const getCodecFlow = function(port, type) {\n+    if (!codecFlow[type]) {\n+        throw port.errors.codecFlowNotFound({type});\n+    }\n+    var ef = codecFlow[type].reduce((accum, f) => { // search for methods in port, get the method and correct context, then exec the method within context\n+        let callCtx = port; // default method\n+        let callMethod = port[f[0]]; // default method ctx\n+\n+        if (f.length > 1 && port[f[0]] && port[f[0]][f[1]]) { // if there is method called from codec like this port.codec.encode, ctx should be codec not port\n+            callCtx = port[f[0]];\n+            callMethod = port[f[0]][f[1]];\n+        }\n+        callMethod && accum.push((encodePacket, $meta, context) => {\n+            return Promise.resolve(callMethod.call(callCtx, encodePacket, $meta, context)); // call the method within ctx\n+        });\n+        return accum;\n+    }, []);\n+    var efLen = ef.length;\n+    return (encodePacket, $meta, context) => {\n+        if (!efLen) {\n+            return encodePacket;\n+        }\n+        return ef.reduce((p, f) => {\n+            return p.then((p) => (f(p, $meta, context)));","path":"port.js","position":32,"original_position":32,"commit_id":"d05a7dd1bc3551eb4f0762579587e0931e7d8dd9","original_commit_id":"d05a7dd1bc3551eb4f0762579587e0931e7d8dd9","user":{"login":"kalinkrustev","id":3054299,"avatar_url":"https://avatars3.githubusercontent.com/u/3054299?v=4","gravatar_id":"","url":"https://api.github.com/users/kalinkrustev","html_url":"https://github.com/kalinkrustev","followers_url":"https://api.github.com/users/kalinkrustev/followers","following_url":"https://api.github.com/users/kalinkrustev/following{/other_user}","gists_url":"https://api.github.com/users/kalinkrustev/gists{/gist_id}","starred_url":"https://api.github.com/users/kalinkrustev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalinkrustev/subscriptions","organizations_url":"https://api.github.com/users/kalinkrustev/orgs","repos_url":"https://api.github.com/users/kalinkrustev/repos","events_url":"https://api.github.com/users/kalinkrustev/events{/privacy}","received_events_url":"https://api.github.com/users/kalinkrustev/received_events","type":"User","site_admin":false},"body":"Why so many brackets?\r\nThis can be simple p => f(p, $meta, context)","created_at":"2018-03-22T01:48:17Z","updated_at":"2018-03-22T01:48:50Z","html_url":"https://github.com/softwaregroup-bg/ut-port/pull/9#discussion_r176289367","pull_request_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/comments/176289367"},"html":{"href":"https://github.com/softwaregroup-bg/ut-port/pull/9#discussion_r176289367"},"pull_request":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9","id":171016598,"html_url":"https://github.com/softwaregroup-bg/ut-port/pull/9","diff_url":"https://github.com/softwaregroup-bg/ut-port/pull/9.diff","patch_url":"https://github.com/softwaregroup-bg/ut-port/pull/9.patch","issue_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/9","number":9,"state":"open","locked":false,"title":"WIP fix: before/after encode functionality","user":{"login":"zetxx","id":704384,"avatar_url":"https://avatars0.githubusercontent.com/u/704384?v=4","gravatar_id":"","url":"https://api.github.com/users/zetxx","html_url":"https://github.com/zetxx","followers_url":"https://api.github.com/users/zetxx/followers","following_url":"https://api.github.com/users/zetxx/following{/other_user}","gists_url":"https://api.github.com/users/zetxx/gists{/gist_id}","starred_url":"https://api.github.com/users/zetxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zetxx/subscriptions","organizations_url":"https://api.github.com/users/zetxx/orgs","repos_url":"https://api.github.com/users/zetxx/repos","events_url":"https://api.github.com/users/zetxx/events{/privacy}","received_events_url":"https://api.github.com/users/zetxx/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-23T13:37:53Z","updated_at":"2018-03-22T01:48:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c941bba422849132e8defbe91748a1412dd32656","assignee":{"login":"kalinkrustev","id":3054299,"avatar_url":"https://avatars3.githubusercontent.com/u/3054299?v=4","gravatar_id":"","url":"https://api.github.com/users/kalinkrustev","html_url":"https://github.com/kalinkrustev","followers_url":"https://api.github.com/users/kalinkrustev/followers","following_url":"https://api.github.com/users/kalinkrustev/following{/other_user}","gists_url":"https://api.github.com/users/kalinkrustev/gists{/gist_id}","starred_url":"https://api.github.com/users/kalinkrustev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalinkrustev/subscriptions","organizations_url":"https://api.github.com/users/kalinkrustev/orgs","repos_url":"https://api.github.com/users/kalinkrustev/repos","events_url":"https://api.github.com/users/kalinkrustev/events{/privacy}","received_events_url":"https://api.github.com/users/kalinkrustev/received_events","type":"User","site_admin":false},"assignees":[{"login":"kalinkrustev","id":3054299,"avatar_url":"https://avatars3.githubusercontent.com/u/3054299?v=4","gravatar_id":"","url":"https://api.github.com/users/kalinkrustev","html_url":"https://github.com/kalinkrustev","followers_url":"https://api.github.com/users/kalinkrustev/followers","following_url":"https://api.github.com/users/kalinkrustev/following{/other_user}","gists_url":"https://api.github.com/users/kalinkrustev/gists{/gist_id}","starred_url":"https://api.github.com/users/kalinkrustev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalinkrustev/subscriptions","organizations_url":"https://api.github.com/users/kalinkrustev/orgs","repos_url":"https://api.github.com/users/kalinkrustev/repos","events_url":"https://api.github.com/users/kalinkrustev/events{/privacy}","received_events_url":"https://api.github.com/users/kalinkrustev/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"stambata","id":6398208,"avatar_url":"https://avatars1.githubusercontent.com/u/6398208?v=4","gravatar_id":"","url":"https://api.github.com/users/stambata","html_url":"https://github.com/stambata","followers_url":"https://api.github.com/users/stambata/followers","following_url":"https://api.github.com/users/stambata/following{/other_user}","gists_url":"https://api.github.com/users/stambata/gists{/gist_id}","starred_url":"https://api.github.com/users/stambata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stambata/subscriptions","organizations_url":"https://api.github.com/users/stambata/orgs","repos_url":"https://api.github.com/users/stambata/repos","events_url":"https://api.github.com/users/stambata/events{/privacy}","received_events_url":"https://api.github.com/users/stambata/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9/commits","review_comments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9/comments","review_comment_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/comments{/number}","comments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/9/comments","statuses_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/statuses/d05a7dd1bc3551eb4f0762579587e0931e7d8dd9","head":{"label":"softwaregroup-bg:beforeAfterEncode","ref":"beforeAfterEncode","sha":"d05a7dd1bc3551eb4f0762579587e0931e7d8dd9","user":{"login":"softwaregroup-bg","id":2078910,"avatar_url":"https://avatars0.githubusercontent.com/u/2078910?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaregroup-bg","html_url":"https://github.com/softwaregroup-bg","followers_url":"https://api.github.com/users/softwaregroup-bg/followers","following_url":"https://api.github.com/users/softwaregroup-bg/following{/other_user}","gists_url":"https://api.github.com/users/softwaregroup-bg/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaregroup-bg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaregroup-bg/subscriptions","organizations_url":"https://api.github.com/users/softwaregroup-bg/orgs","repos_url":"https://api.github.com/users/softwaregroup-bg/repos","events_url":"https://api.github.com/users/softwaregroup-bg/events{/privacy}","received_events_url":"https://api.github.com/users/softwaregroup-bg/received_events","type":"Organization","site_admin":false},"repo":{"id":106476682,"name":"ut-port","full_name":"softwaregroup-bg/ut-port","owner":{"login":"softwaregroup-bg","id":2078910,"avatar_url":"https://avatars0.githubusercontent.com/u/2078910?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaregroup-bg","html_url":"https://github.com/softwaregroup-bg","followers_url":"https://api.github.com/users/softwaregroup-bg/followers","following_url":"https://api.github.com/users/softwaregroup-bg/following{/other_user}","gists_url":"https://api.github.com/users/softwaregroup-bg/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaregroup-bg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaregroup-bg/subscriptions","organizations_url":"https://api.github.com/users/softwaregroup-bg/orgs","repos_url":"https://api.github.com/users/softwaregroup-bg/repos","events_url":"https://api.github.com/users/softwaregroup-bg/events{/privacy}","received_events_url":"https://api.github.com/users/softwaregroup-bg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/softwaregroup-bg/ut-port","description":null,"fork":false,"url":"https://api.github.com/repos/softwaregroup-bg/ut-port","forks_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/forks","keys_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/teams","hooks_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/hooks","issue_events_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/events{/number}","events_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/events","assignees_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/assignees{/user}","branches_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/branches{/branch}","tags_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/tags","blobs_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/refs{/sha}","trees_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/statuses/{sha}","languages_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/languages","stargazers_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/stargazers","contributors_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/contributors","subscribers_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/subscribers","subscription_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/subscription","commits_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/commits{/sha}","git_commits_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/commits{/sha}","comments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/comments{/number}","issue_comment_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/comments{/number}","contents_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/contents/{+path}","compare_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/merges","archive_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/downloads","issues_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues{/number}","pulls_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls{/number}","milestones_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/milestones{/number}","notifications_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/labels{/name}","releases_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/releases{/id}","deployments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/deployments","created_at":"2017-10-10T22:07:41Z","updated_at":"2017-10-10T22:16:17Z","pushed_at":"2018-03-19T15:53:34Z","git_url":"git://github.com/softwaregroup-bg/ut-port.git","ssh_url":"git@github.com:softwaregroup-bg/ut-port.git","clone_url":"https://github.com/softwaregroup-bg/ut-port.git","svn_url":"https://github.com/softwaregroup-bg/ut-port","homepage":null,"size":106,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"softwaregroup-bg:master","ref":"master","sha":"e5b43457727e6bcc6c975bc46b96920b3b828fe6","user":{"login":"softwaregroup-bg","id":2078910,"avatar_url":"https://avatars0.githubusercontent.com/u/2078910?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaregroup-bg","html_url":"https://github.com/softwaregroup-bg","followers_url":"https://api.github.com/users/softwaregroup-bg/followers","following_url":"https://api.github.com/users/softwaregroup-bg/following{/other_user}","gists_url":"https://api.github.com/users/softwaregroup-bg/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaregroup-bg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaregroup-bg/subscriptions","organizations_url":"https://api.github.com/users/softwaregroup-bg/orgs","repos_url":"https://api.github.com/users/softwaregroup-bg/repos","events_url":"https://api.github.com/users/softwaregroup-bg/events{/privacy}","received_events_url":"https://api.github.com/users/softwaregroup-bg/received_events","type":"Organization","site_admin":false},"repo":{"id":106476682,"name":"ut-port","full_name":"softwaregroup-bg/ut-port","owner":{"login":"softwaregroup-bg","id":2078910,"avatar_url":"https://avatars0.githubusercontent.com/u/2078910?v=4","gravatar_id":"","url":"https://api.github.com/users/softwaregroup-bg","html_url":"https://github.com/softwaregroup-bg","followers_url":"https://api.github.com/users/softwaregroup-bg/followers","following_url":"https://api.github.com/users/softwaregroup-bg/following{/other_user}","gists_url":"https://api.github.com/users/softwaregroup-bg/gists{/gist_id}","starred_url":"https://api.github.com/users/softwaregroup-bg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/softwaregroup-bg/subscriptions","organizations_url":"https://api.github.com/users/softwaregroup-bg/orgs","repos_url":"https://api.github.com/users/softwaregroup-bg/repos","events_url":"https://api.github.com/users/softwaregroup-bg/events{/privacy}","received_events_url":"https://api.github.com/users/softwaregroup-bg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/softwaregroup-bg/ut-port","description":null,"fork":false,"url":"https://api.github.com/repos/softwaregroup-bg/ut-port","forks_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/forks","keys_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/keys{/key_id}","collaborators_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/teams","hooks_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/hooks","issue_events_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/events{/number}","events_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/events","assignees_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/assignees{/user}","branches_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/branches{/branch}","tags_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/tags","blobs_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/refs{/sha}","trees_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/trees{/sha}","statuses_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/statuses/{sha}","languages_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/languages","stargazers_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/stargazers","contributors_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/contributors","subscribers_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/subscribers","subscription_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/subscription","commits_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/commits{/sha}","git_commits_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/git/commits{/sha}","comments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/comments{/number}","issue_comment_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/comments{/number}","contents_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/contents/{+path}","compare_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/compare/{base}...{head}","merges_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/merges","archive_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/downloads","issues_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues{/number}","pulls_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls{/number}","milestones_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/milestones{/number}","notifications_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/labels{/name}","releases_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/releases{/id}","deployments_url":"https://api.github.com/repos/softwaregroup-bg/ut-port/deployments","created_at":"2017-10-10T22:07:41Z","updated_at":"2017-10-10T22:16:17Z","pushed_at":"2018-03-19T15:53:34Z","git_url":"git://github.com/softwaregroup-bg/ut-port.git","ssh_url":"git@github.com:softwaregroup-bg/ut-port.git","clone_url":"https://github.com/softwaregroup-bg/ut-port.git","svn_url":"https://github.com/softwaregroup-bg/ut-port","homepage":null,"size":106,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9"},"html":{"href":"https://github.com/softwaregroup-bg/ut-port/pull/9"},"issue":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/9"},"comments":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/softwaregroup-bg/ut-port/statuses/d05a7dd1bc3551eb4f0762579587e0931e7d8dd9"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kalinkrustev"}}