{"action":"created","comment":{"url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/comments/64699780","id":64699780,"diff_hunk":"@@ -29,12 +29,22 @@ function defaultId () {\n }\n \n function sendPacket (client, packet, cb) {\n+  function emitAndCb () {\n+    if ('publish' === packet.cmd) {\n+      client.emit('publish', packet.topic, packet.payload, packet);\n+    }\n+    if (cb) {\n+      cb();\n+    }\n+  }","path":"lib/client.js","position":11,"original_position":11,"commit_id":"24dd5496fe8b47969c95a2900371535347ec50c7","original_commit_id":"24dd5496fe8b47969c95a2900371535347ec50c7","user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars.githubusercontent.com/u/52195?v=3","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"body":"Using a function here is definitely not ok, as it will cause a perceivable slowdown in the benchmarks (at least in #345). Moreover, this function will be allocated even for every other packet (where there is no need).","created_at":"2016-05-26T07:05:56Z","updated_at":"2016-05-26T07:05:56Z","html_url":"https://github.com/mqttjs/MQTT.js/pull/410#discussion_r64699780","pull_request_url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410","_links":{"self":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/comments/64699780"},"html":{"href":"https://github.com/mqttjs/MQTT.js/pull/410#discussion_r64699780"},"pull_request":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410"}}},"pull_request":{"url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410","id":71148492,"html_url":"https://github.com/mqttjs/MQTT.js/pull/410","diff_url":"https://github.com/mqttjs/MQTT.js/pull/410.diff","patch_url":"https://github.com/mqttjs/MQTT.js/pull/410.patch","issue_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/410","number":410,"state":"open","locked":false,"title":"Add publish event to mqtt.Client","user":{"login":"Densaugeo","id":1566372,"avatar_url":"https://avatars.githubusercontent.com/u/1566372?v=3","gravatar_id":"","url":"https://api.github.com/users/Densaugeo","html_url":"https://github.com/Densaugeo","followers_url":"https://api.github.com/users/Densaugeo/followers","following_url":"https://api.github.com/users/Densaugeo/following{/other_user}","gists_url":"https://api.github.com/users/Densaugeo/gists{/gist_id}","starred_url":"https://api.github.com/users/Densaugeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Densaugeo/subscriptions","organizations_url":"https://api.github.com/users/Densaugeo/orgs","repos_url":"https://api.github.com/users/Densaugeo/repos","events_url":"https://api.github.com/users/Densaugeo/events{/privacy}","received_events_url":"https://api.github.com/users/Densaugeo/received_events","type":"User","site_admin":false},"body":"For #407.","created_at":"2016-05-24T02:15:36Z","updated_at":"2016-05-26T07:05:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2a4739cd9f2066cce67bf93770948edb2314174","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410/commits","review_comments_url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410/comments","review_comment_url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/410/comments","statuses_url":"https://api.github.com/repos/mqttjs/MQTT.js/statuses/24dd5496fe8b47969c95a2900371535347ec50c7","head":{"label":"Densaugeo:master","ref":"master","sha":"24dd5496fe8b47969c95a2900371535347ec50c7","user":{"login":"Densaugeo","id":1566372,"avatar_url":"https://avatars.githubusercontent.com/u/1566372?v=3","gravatar_id":"","url":"https://api.github.com/users/Densaugeo","html_url":"https://github.com/Densaugeo","followers_url":"https://api.github.com/users/Densaugeo/followers","following_url":"https://api.github.com/users/Densaugeo/following{/other_user}","gists_url":"https://api.github.com/users/Densaugeo/gists{/gist_id}","starred_url":"https://api.github.com/users/Densaugeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Densaugeo/subscriptions","organizations_url":"https://api.github.com/users/Densaugeo/orgs","repos_url":"https://api.github.com/users/Densaugeo/repos","events_url":"https://api.github.com/users/Densaugeo/events{/privacy}","received_events_url":"https://api.github.com/users/Densaugeo/received_events","type":"User","site_admin":false},"repo":{"id":59528665,"name":"MQTT.js","full_name":"Densaugeo/MQTT.js","owner":{"login":"Densaugeo","id":1566372,"avatar_url":"https://avatars.githubusercontent.com/u/1566372?v=3","gravatar_id":"","url":"https://api.github.com/users/Densaugeo","html_url":"https://github.com/Densaugeo","followers_url":"https://api.github.com/users/Densaugeo/followers","following_url":"https://api.github.com/users/Densaugeo/following{/other_user}","gists_url":"https://api.github.com/users/Densaugeo/gists{/gist_id}","starred_url":"https://api.github.com/users/Densaugeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Densaugeo/subscriptions","organizations_url":"https://api.github.com/users/Densaugeo/orgs","repos_url":"https://api.github.com/users/Densaugeo/repos","events_url":"https://api.github.com/users/Densaugeo/events{/privacy}","received_events_url":"https://api.github.com/users/Densaugeo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Densaugeo/MQTT.js","description":"The MQTT client for Node.js and the browser","fork":true,"url":"https://api.github.com/repos/Densaugeo/MQTT.js","forks_url":"https://api.github.com/repos/Densaugeo/MQTT.js/forks","keys_url":"https://api.github.com/repos/Densaugeo/MQTT.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Densaugeo/MQTT.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Densaugeo/MQTT.js/teams","hooks_url":"https://api.github.com/repos/Densaugeo/MQTT.js/hooks","issue_events_url":"https://api.github.com/repos/Densaugeo/MQTT.js/issues/events{/number}","events_url":"https://api.github.com/repos/Densaugeo/MQTT.js/events","assignees_url":"https://api.github.com/repos/Densaugeo/MQTT.js/assignees{/user}","branches_url":"https://api.github.com/repos/Densaugeo/MQTT.js/branches{/branch}","tags_url":"https://api.github.com/repos/Densaugeo/MQTT.js/tags","blobs_url":"https://api.github.com/repos/Densaugeo/MQTT.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Densaugeo/MQTT.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Densaugeo/MQTT.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/Densaugeo/MQTT.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Densaugeo/MQTT.js/statuses/{sha}","languages_url":"https://api.github.com/repos/Densaugeo/MQTT.js/languages","stargazers_url":"https://api.github.com/repos/Densaugeo/MQTT.js/stargazers","contributors_url":"https://api.github.com/repos/Densaugeo/MQTT.js/contributors","subscribers_url":"https://api.github.com/repos/Densaugeo/MQTT.js/subscribers","subscription_url":"https://api.github.com/repos/Densaugeo/MQTT.js/subscription","commits_url":"https://api.github.com/repos/Densaugeo/MQTT.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/Densaugeo/MQTT.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/Densaugeo/MQTT.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/Densaugeo/MQTT.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/Densaugeo/MQTT.js/contents/{+path}","compare_url":"https://api.github.com/repos/Densaugeo/MQTT.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Densaugeo/MQTT.js/merges","archive_url":"https://api.github.com/repos/Densaugeo/MQTT.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Densaugeo/MQTT.js/downloads","issues_url":"https://api.github.com/repos/Densaugeo/MQTT.js/issues{/number}","pulls_url":"https://api.github.com/repos/Densaugeo/MQTT.js/pulls{/number}","milestones_url":"https://api.github.com/repos/Densaugeo/MQTT.js/milestones{/number}","notifications_url":"https://api.github.com/repos/Densaugeo/MQTT.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Densaugeo/MQTT.js/labels{/name}","releases_url":"https://api.github.com/repos/Densaugeo/MQTT.js/releases{/id}","deployments_url":"https://api.github.com/repos/Densaugeo/MQTT.js/deployments","created_at":"2016-05-24T00:52:15Z","updated_at":"2016-05-24T00:52:16Z","pushed_at":"2016-05-26T03:09:39Z","git_url":"git://github.com/Densaugeo/MQTT.js.git","ssh_url":"git@github.com:Densaugeo/MQTT.js.git","clone_url":"https://github.com/Densaugeo/MQTT.js.git","svn_url":"https://github.com/Densaugeo/MQTT.js","homepage":"","size":1040,"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":"mqttjs:master","ref":"master","sha":"0a965321e089a2cb4d5695b1610ca3f67722df04","user":{"login":"mqttjs","id":10424911,"avatar_url":"https://avatars.githubusercontent.com/u/10424911?v=3","gravatar_id":"","url":"https://api.github.com/users/mqttjs","html_url":"https://github.com/mqttjs","followers_url":"https://api.github.com/users/mqttjs/followers","following_url":"https://api.github.com/users/mqttjs/following{/other_user}","gists_url":"https://api.github.com/users/mqttjs/gists{/gist_id}","starred_url":"https://api.github.com/users/mqttjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqttjs/subscriptions","organizations_url":"https://api.github.com/users/mqttjs/orgs","repos_url":"https://api.github.com/users/mqttjs/repos","events_url":"https://api.github.com/users/mqttjs/events{/privacy}","received_events_url":"https://api.github.com/users/mqttjs/received_events","type":"Organization","site_admin":false},"repo":{"id":1569980,"name":"MQTT.js","full_name":"mqttjs/MQTT.js","owner":{"login":"mqttjs","id":10424911,"avatar_url":"https://avatars.githubusercontent.com/u/10424911?v=3","gravatar_id":"","url":"https://api.github.com/users/mqttjs","html_url":"https://github.com/mqttjs","followers_url":"https://api.github.com/users/mqttjs/followers","following_url":"https://api.github.com/users/mqttjs/following{/other_user}","gists_url":"https://api.github.com/users/mqttjs/gists{/gist_id}","starred_url":"https://api.github.com/users/mqttjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqttjs/subscriptions","organizations_url":"https://api.github.com/users/mqttjs/orgs","repos_url":"https://api.github.com/users/mqttjs/repos","events_url":"https://api.github.com/users/mqttjs/events{/privacy}","received_events_url":"https://api.github.com/users/mqttjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mqttjs/MQTT.js","description":"The MQTT client for Node.js and the browser","fork":false,"url":"https://api.github.com/repos/mqttjs/MQTT.js","forks_url":"https://api.github.com/repos/mqttjs/MQTT.js/forks","keys_url":"https://api.github.com/repos/mqttjs/MQTT.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mqttjs/MQTT.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mqttjs/MQTT.js/teams","hooks_url":"https://api.github.com/repos/mqttjs/MQTT.js/hooks","issue_events_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/events{/number}","events_url":"https://api.github.com/repos/mqttjs/MQTT.js/events","assignees_url":"https://api.github.com/repos/mqttjs/MQTT.js/assignees{/user}","branches_url":"https://api.github.com/repos/mqttjs/MQTT.js/branches{/branch}","tags_url":"https://api.github.com/repos/mqttjs/MQTT.js/tags","blobs_url":"https://api.github.com/repos/mqttjs/MQTT.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mqttjs/MQTT.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mqttjs/MQTT.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/mqttjs/MQTT.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mqttjs/MQTT.js/statuses/{sha}","languages_url":"https://api.github.com/repos/mqttjs/MQTT.js/languages","stargazers_url":"https://api.github.com/repos/mqttjs/MQTT.js/stargazers","contributors_url":"https://api.github.com/repos/mqttjs/MQTT.js/contributors","subscribers_url":"https://api.github.com/repos/mqttjs/MQTT.js/subscribers","subscription_url":"https://api.github.com/repos/mqttjs/MQTT.js/subscription","commits_url":"https://api.github.com/repos/mqttjs/MQTT.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/mqttjs/MQTT.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/mqttjs/MQTT.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/mqttjs/MQTT.js/contents/{+path}","compare_url":"https://api.github.com/repos/mqttjs/MQTT.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mqttjs/MQTT.js/merges","archive_url":"https://api.github.com/repos/mqttjs/MQTT.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mqttjs/MQTT.js/downloads","issues_url":"https://api.github.com/repos/mqttjs/MQTT.js/issues{/number}","pulls_url":"https://api.github.com/repos/mqttjs/MQTT.js/pulls{/number}","milestones_url":"https://api.github.com/repos/mqttjs/MQTT.js/milestones{/number}","notifications_url":"https://api.github.com/repos/mqttjs/MQTT.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mqttjs/MQTT.js/labels{/name}","releases_url":"https://api.github.com/repos/mqttjs/MQTT.js/releases{/id}","deployments_url":"https://api.github.com/repos/mqttjs/MQTT.js/deployments","created_at":"2011-04-05T00:33:23Z","updated_at":"2016-05-25T14:18:12Z","pushed_at":"2016-05-26T03:09:41Z","git_url":"git://github.com/mqttjs/MQTT.js.git","ssh_url":"git@github.com:mqttjs/MQTT.js.git","clone_url":"https://github.com/mqttjs/MQTT.js.git","svn_url":"https://github.com/mqttjs/MQTT.js","homepage":"","size":1440,"stargazers_count":1412,"watchers_count":1412,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":315,"mirror_url":null,"open_issues_count":48,"forks":315,"open_issues":48,"watchers":1412,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410"},"html":{"href":"https://github.com/mqttjs/MQTT.js/pull/410"},"issue":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/issues/410"},"comments":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/issues/410/comments"},"review_comments":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410/comments"},"review_comment":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/pulls/410/commits"},"statuses":{"href":"https://api.github.com/repos/mqttjs/MQTT.js/statuses/24dd5496fe8b47969c95a2900371535347ec50c7"}}}}
{"actor":{"display_login":"mcollina"}}