{"action":"created","comment":{"url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/comments/36910066","id":36910066,"diff_hunk":"@@ -17,6 +19,21 @@ module.exports = function (str, cb) {\n \t});\n };\n \n+module.exports.stream = function () {\n+\tvar size = 0;\n+\treturn zlib.createGzip(opts)\n+\t\t.on('data', function (buf) {\n+\t\t\tsize += buf.length;\n+\t\t})\n+\t\t.on('error', function () {\n+\t\t\tthis.size = 0;\n+\t\t})\n+\t\t.on('end', function () {\n+\t\t\tthis.size = size;\n+\t\t\tthis.emit('size', size);\n+\t\t});\n+};","path":"index.js","position":34,"original_position":34,"commit_id":"11cc9836efec194bbb316299f5f79811066cb626","original_commit_id":"11cc9836efec194bbb316299f5f79811066cb626","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"body":"Actually, I don't think it makes sense to return the gzip stream. The user only cares about the gzipped size. They don't actually want their stream gzipped. Rather return a passthrough stream with the event and property. I would also make the event name `gzip-size` and property `gzipSize` just to be explicit.","created_at":"2015-08-12T20:32:30Z","updated_at":"2015-08-12T20:32:30Z","html_url":"https://github.com/sindresorhus/gzip-size/pull/7#discussion_r36910066","pull_request_url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/comments/36910066"},"html":{"href":"https://github.com/sindresorhus/gzip-size/pull/7#discussion_r36910066"},"pull_request":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7","id":42084179,"html_url":"https://github.com/sindresorhus/gzip-size/pull/7","diff_url":"https://github.com/sindresorhus/gzip-size/pull/7.diff","patch_url":"https://github.com/sindresorhus/gzip-size/pull/7.patch","issue_url":"https://api.github.com/repos/sindresorhus/gzip-size/issues/7","number":7,"state":"open","locked":false,"title":"add stream support","user":{"login":"zertosh","id":830952,"avatar_url":"https://avatars.githubusercontent.com/u/830952?v=3","gravatar_id":"","url":"https://api.github.com/users/zertosh","html_url":"https://github.com/zertosh","followers_url":"https://api.github.com/users/zertosh/followers","following_url":"https://api.github.com/users/zertosh/following{/other_user}","gists_url":"https://api.github.com/users/zertosh/gists{/gist_id}","starred_url":"https://api.github.com/users/zertosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zertosh/subscriptions","organizations_url":"https://api.github.com/users/zertosh/orgs","repos_url":"https://api.github.com/users/zertosh/repos","events_url":"https://api.github.com/users/zertosh/events{/privacy}","received_events_url":"https://api.github.com/users/zertosh/received_events","type":"User","site_admin":false},"body":"Adds stream support to gzip-size so I can then add stream support to [gulp-size](https://github.com/sindresorhus/gulp-size). cc: @sindresorhus ","created_at":"2015-08-11T01:26:51Z","updated_at":"2015-08-12T20:32:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67f6105a9493fab7c5a36a613a628b3c6bc57552","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7/commits","review_comments_url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7/comments","review_comment_url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sindresorhus/gzip-size/issues/7/comments","statuses_url":"https://api.github.com/repos/sindresorhus/gzip-size/statuses/11cc9836efec194bbb316299f5f79811066cb626","head":{"label":"zertosh:stream-support","ref":"stream-support","sha":"11cc9836efec194bbb316299f5f79811066cb626","user":{"login":"zertosh","id":830952,"avatar_url":"https://avatars.githubusercontent.com/u/830952?v=3","gravatar_id":"","url":"https://api.github.com/users/zertosh","html_url":"https://github.com/zertosh","followers_url":"https://api.github.com/users/zertosh/followers","following_url":"https://api.github.com/users/zertosh/following{/other_user}","gists_url":"https://api.github.com/users/zertosh/gists{/gist_id}","starred_url":"https://api.github.com/users/zertosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zertosh/subscriptions","organizations_url":"https://api.github.com/users/zertosh/orgs","repos_url":"https://api.github.com/users/zertosh/repos","events_url":"https://api.github.com/users/zertosh/events{/privacy}","received_events_url":"https://api.github.com/users/zertosh/received_events","type":"User","site_admin":false},"repo":{"id":40514457,"name":"gzip-size","full_name":"zertosh/gzip-size","owner":{"login":"zertosh","id":830952,"avatar_url":"https://avatars.githubusercontent.com/u/830952?v=3","gravatar_id":"","url":"https://api.github.com/users/zertosh","html_url":"https://github.com/zertosh","followers_url":"https://api.github.com/users/zertosh/followers","following_url":"https://api.github.com/users/zertosh/following{/other_user}","gists_url":"https://api.github.com/users/zertosh/gists{/gist_id}","starred_url":"https://api.github.com/users/zertosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zertosh/subscriptions","organizations_url":"https://api.github.com/users/zertosh/orgs","repos_url":"https://api.github.com/users/zertosh/repos","events_url":"https://api.github.com/users/zertosh/events{/privacy}","received_events_url":"https://api.github.com/users/zertosh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zertosh/gzip-size","description":"Get the gzipped size of a string or buffer","fork":true,"url":"https://api.github.com/repos/zertosh/gzip-size","forks_url":"https://api.github.com/repos/zertosh/gzip-size/forks","keys_url":"https://api.github.com/repos/zertosh/gzip-size/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zertosh/gzip-size/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zertosh/gzip-size/teams","hooks_url":"https://api.github.com/repos/zertosh/gzip-size/hooks","issue_events_url":"https://api.github.com/repos/zertosh/gzip-size/issues/events{/number}","events_url":"https://api.github.com/repos/zertosh/gzip-size/events","assignees_url":"https://api.github.com/repos/zertosh/gzip-size/assignees{/user}","branches_url":"https://api.github.com/repos/zertosh/gzip-size/branches{/branch}","tags_url":"https://api.github.com/repos/zertosh/gzip-size/tags","blobs_url":"https://api.github.com/repos/zertosh/gzip-size/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zertosh/gzip-size/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zertosh/gzip-size/git/refs{/sha}","trees_url":"https://api.github.com/repos/zertosh/gzip-size/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zertosh/gzip-size/statuses/{sha}","languages_url":"https://api.github.com/repos/zertosh/gzip-size/languages","stargazers_url":"https://api.github.com/repos/zertosh/gzip-size/stargazers","contributors_url":"https://api.github.com/repos/zertosh/gzip-size/contributors","subscribers_url":"https://api.github.com/repos/zertosh/gzip-size/subscribers","subscription_url":"https://api.github.com/repos/zertosh/gzip-size/subscription","commits_url":"https://api.github.com/repos/zertosh/gzip-size/commits{/sha}","git_commits_url":"https://api.github.com/repos/zertosh/gzip-size/git/commits{/sha}","comments_url":"https://api.github.com/repos/zertosh/gzip-size/comments{/number}","issue_comment_url":"https://api.github.com/repos/zertosh/gzip-size/issues/comments{/number}","contents_url":"https://api.github.com/repos/zertosh/gzip-size/contents/{+path}","compare_url":"https://api.github.com/repos/zertosh/gzip-size/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zertosh/gzip-size/merges","archive_url":"https://api.github.com/repos/zertosh/gzip-size/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zertosh/gzip-size/downloads","issues_url":"https://api.github.com/repos/zertosh/gzip-size/issues{/number}","pulls_url":"https://api.github.com/repos/zertosh/gzip-size/pulls{/number}","milestones_url":"https://api.github.com/repos/zertosh/gzip-size/milestones{/number}","notifications_url":"https://api.github.com/repos/zertosh/gzip-size/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zertosh/gzip-size/labels{/name}","releases_url":"https://api.github.com/repos/zertosh/gzip-size/releases{/id}","created_at":"2015-08-11T01:23:52Z","updated_at":"2015-08-11T01:23:53Z","pushed_at":"2015-08-11T16:08:34Z","git_url":"git://github.com/zertosh/gzip-size.git","ssh_url":"git@github.com:zertosh/gzip-size.git","clone_url":"https://github.com/zertosh/gzip-size.git","svn_url":"https://github.com/zertosh/gzip-size","homepage":null,"size":90,"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":"sindresorhus:master","ref":"master","sha":"665767b0ab765497c4e8611cc04e2c485bfc2064","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":17297834,"name":"gzip-size","full_name":"sindresorhus/gzip-size","owner":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/gzip-size","description":"Get the gzipped size of a string or buffer","fork":false,"url":"https://api.github.com/repos/sindresorhus/gzip-size","forks_url":"https://api.github.com/repos/sindresorhus/gzip-size/forks","keys_url":"https://api.github.com/repos/sindresorhus/gzip-size/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/gzip-size/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/gzip-size/teams","hooks_url":"https://api.github.com/repos/sindresorhus/gzip-size/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/gzip-size/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/gzip-size/events","assignees_url":"https://api.github.com/repos/sindresorhus/gzip-size/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/gzip-size/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/gzip-size/tags","blobs_url":"https://api.github.com/repos/sindresorhus/gzip-size/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/gzip-size/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/gzip-size/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/gzip-size/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/gzip-size/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/gzip-size/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/gzip-size/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/gzip-size/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/gzip-size/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/gzip-size/subscription","commits_url":"https://api.github.com/repos/sindresorhus/gzip-size/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/gzip-size/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/gzip-size/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/gzip-size/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/gzip-size/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/gzip-size/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/gzip-size/merges","archive_url":"https://api.github.com/repos/sindresorhus/gzip-size/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/gzip-size/downloads","issues_url":"https://api.github.com/repos/sindresorhus/gzip-size/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/gzip-size/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/gzip-size/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/gzip-size/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/gzip-size/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/gzip-size/releases{/id}","created_at":"2014-02-28T19:55:14Z","updated_at":"2015-07-02T07:22:13Z","pushed_at":"2015-08-11T16:08:35Z","git_url":"git://github.com/sindresorhus/gzip-size.git","ssh_url":"git@github.com:sindresorhus/gzip-size.git","clone_url":"https://github.com/sindresorhus/gzip-size.git","svn_url":"https://github.com/sindresorhus/gzip-size","homepage":null,"size":218,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7"},"html":{"href":"https://github.com/sindresorhus/gzip-size/pull/7"},"issue":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/issues/7"},"comments":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/sindresorhus/gzip-size/statuses/11cc9836efec194bbb316299f5f79811066cb626"}}}}