{"action":"created","comment":{"url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/comments/171141656","pull_request_review_id":99941742,"id":171141656,"diff_hunk":"@@ -0,0 +1,55 @@\n+'use strict';\n+\n+const bytes = require('humanize-bytes');\n+\n+module.exports = (stream, options = {}) => {\n+  return new Promise((resolve, reject) => {\n+    if (!stream.readable) return resolve();\n+    const maxSize = options.maxSize && bytes(options.maxSize);\n+\n+    let bufs = [];\n+    let size = 0;\n+    let error;\n+\n+    stream.on('data', onData);\n+    stream.on('end', onEnd);\n+    stream.on('error', onEnd);\n+    stream.on('close', onClose);\n+\n+    function onData(buf) {\n+      if (error) return;\n+\n+      size += buf.length;\n+      if (maxSize && size > maxSize) {\n+        error = new Error(`stream buffer size exceed ${options.maxSize}`);\n+        error.code = 'EXCEED_MAX_SIZE';\n+        return;\n+      }\n+      bufs.push(buf);\n+    }\n+\n+    function onEnd(err) {\n+      if (err instanceof Error) error = err;\n+      done();\n+    }\n+\n+    function onClose() {\n+      done();\n+    }\n+\n+    function done() {\n+      if (error) reject(error);\n+      else resolve(Buffer.concat(bufs));\n+      cleanup();","path":"index.js","position":43,"original_position":43,"commit_id":"66a56d003aaeb46e48547f3f475f96a9a36dc2fb","original_commit_id":"66a56d003aaeb46e48547f3f475f96a9a36dc2fb","user":{"login":"popomore","id":360661,"avatar_url":"https://avatars1.githubusercontent.com/u/360661?v=4","gravatar_id":"","url":"https://api.github.com/users/popomore","html_url":"https://github.com/popomore","followers_url":"https://api.github.com/users/popomore/followers","following_url":"https://api.github.com/users/popomore/following{/other_user}","gists_url":"https://api.github.com/users/popomore/gists{/gist_id}","starred_url":"https://api.github.com/users/popomore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/popomore/subscriptions","organizations_url":"https://api.github.com/users/popomore/orgs","repos_url":"https://api.github.com/users/popomore/repos","events_url":"https://api.github.com/users/popomore/events{/privacy}","received_events_url":"https://api.github.com/users/popomore/received_events","type":"User","site_admin":false},"body":"先 removeListener?","created_at":"2018-02-28T04:37:17Z","updated_at":"2018-02-28T04:37:17Z","html_url":"https://github.com/node-modules/stream-to-buf/pull/1#discussion_r171141656","pull_request_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/comments/171141656"},"html":{"href":"https://github.com/node-modules/stream-to-buf/pull/1#discussion_r171141656"},"pull_request":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1","id":171850133,"html_url":"https://github.com/node-modules/stream-to-buf/pull/1","diff_url":"https://github.com/node-modules/stream-to-buf/pull/1.diff","patch_url":"https://github.com/node-modules/stream-to-buf/pull/1.patch","issue_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/1","number":1,"state":"open","locked":false,"title":"feat: init stream to buffer","user":{"login":"dead-horse","id":985607,"avatar_url":"https://avatars3.githubusercontent.com/u/985607?v=4","gravatar_id":"","url":"https://api.github.com/users/dead-horse","html_url":"https://github.com/dead-horse","followers_url":"https://api.github.com/users/dead-horse/followers","following_url":"https://api.github.com/users/dead-horse/following{/other_user}","gists_url":"https://api.github.com/users/dead-horse/gists{/gist_id}","starred_url":"https://api.github.com/users/dead-horse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dead-horse/subscriptions","organizations_url":"https://api.github.com/users/dead-horse/orgs","repos_url":"https://api.github.com/users/dead-horse/repos","events_url":"https://api.github.com/users/dead-horse/events{/privacy}","received_events_url":"https://api.github.com/users/dead-horse/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-28T03:56:27Z","updated_at":"2018-02-28T04:37:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"30b6be42d67e4ee27f1989e4218928057c510f37","assignee":null,"assignees":[],"requested_reviewers":[{"login":"fengmk2","id":156269,"avatar_url":"https://avatars0.githubusercontent.com/u/156269?v=4","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1/commits","review_comments_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1/comments","review_comment_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/1/comments","statuses_url":"https://api.github.com/repos/node-modules/stream-to-buf/statuses/66a56d003aaeb46e48547f3f475f96a9a36dc2fb","head":{"label":"node-modules:init","ref":"init","sha":"66a56d003aaeb46e48547f3f475f96a9a36dc2fb","user":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars3.githubusercontent.com/u/7125868?v=4","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"repo":{"id":123222234,"name":"stream-to-buf","full_name":"node-modules/stream-to-buf","owner":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars3.githubusercontent.com/u/7125868?v=4","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/node-modules/stream-to-buf","description":"convert readable stream to buffer with length limit","fork":false,"url":"https://api.github.com/repos/node-modules/stream-to-buf","forks_url":"https://api.github.com/repos/node-modules/stream-to-buf/forks","keys_url":"https://api.github.com/repos/node-modules/stream-to-buf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/node-modules/stream-to-buf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/node-modules/stream-to-buf/teams","hooks_url":"https://api.github.com/repos/node-modules/stream-to-buf/hooks","issue_events_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/events{/number}","events_url":"https://api.github.com/repos/node-modules/stream-to-buf/events","assignees_url":"https://api.github.com/repos/node-modules/stream-to-buf/assignees{/user}","branches_url":"https://api.github.com/repos/node-modules/stream-to-buf/branches{/branch}","tags_url":"https://api.github.com/repos/node-modules/stream-to-buf/tags","blobs_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/refs{/sha}","trees_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/node-modules/stream-to-buf/statuses/{sha}","languages_url":"https://api.github.com/repos/node-modules/stream-to-buf/languages","stargazers_url":"https://api.github.com/repos/node-modules/stream-to-buf/stargazers","contributors_url":"https://api.github.com/repos/node-modules/stream-to-buf/contributors","subscribers_url":"https://api.github.com/repos/node-modules/stream-to-buf/subscribers","subscription_url":"https://api.github.com/repos/node-modules/stream-to-buf/subscription","commits_url":"https://api.github.com/repos/node-modules/stream-to-buf/commits{/sha}","git_commits_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/commits{/sha}","comments_url":"https://api.github.com/repos/node-modules/stream-to-buf/comments{/number}","issue_comment_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/comments{/number}","contents_url":"https://api.github.com/repos/node-modules/stream-to-buf/contents/{+path}","compare_url":"https://api.github.com/repos/node-modules/stream-to-buf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/node-modules/stream-to-buf/merges","archive_url":"https://api.github.com/repos/node-modules/stream-to-buf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/node-modules/stream-to-buf/downloads","issues_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues{/number}","pulls_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls{/number}","milestones_url":"https://api.github.com/repos/node-modules/stream-to-buf/milestones{/number}","notifications_url":"https://api.github.com/repos/node-modules/stream-to-buf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/node-modules/stream-to-buf/labels{/name}","releases_url":"https://api.github.com/repos/node-modules/stream-to-buf/releases{/id}","deployments_url":"https://api.github.com/repos/node-modules/stream-to-buf/deployments","created_at":"2018-02-28T03:13:50Z","updated_at":"2018-02-28T03:53:14Z","pushed_at":"2018-02-28T03:57:36Z","git_url":"git://github.com/node-modules/stream-to-buf.git","ssh_url":"git@github.com:node-modules/stream-to-buf.git","clone_url":"https://github.com/node-modules/stream-to-buf.git","svn_url":"https://github.com/node-modules/stream-to-buf","homepage":null,"size":0,"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":"node-modules:master","ref":"master","sha":"fdd5499358938fec44d388a002233f1e36279735","user":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars3.githubusercontent.com/u/7125868?v=4","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"repo":{"id":123222234,"name":"stream-to-buf","full_name":"node-modules/stream-to-buf","owner":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars3.githubusercontent.com/u/7125868?v=4","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/node-modules/stream-to-buf","description":"convert readable stream to buffer with length limit","fork":false,"url":"https://api.github.com/repos/node-modules/stream-to-buf","forks_url":"https://api.github.com/repos/node-modules/stream-to-buf/forks","keys_url":"https://api.github.com/repos/node-modules/stream-to-buf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/node-modules/stream-to-buf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/node-modules/stream-to-buf/teams","hooks_url":"https://api.github.com/repos/node-modules/stream-to-buf/hooks","issue_events_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/events{/number}","events_url":"https://api.github.com/repos/node-modules/stream-to-buf/events","assignees_url":"https://api.github.com/repos/node-modules/stream-to-buf/assignees{/user}","branches_url":"https://api.github.com/repos/node-modules/stream-to-buf/branches{/branch}","tags_url":"https://api.github.com/repos/node-modules/stream-to-buf/tags","blobs_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/refs{/sha}","trees_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/node-modules/stream-to-buf/statuses/{sha}","languages_url":"https://api.github.com/repos/node-modules/stream-to-buf/languages","stargazers_url":"https://api.github.com/repos/node-modules/stream-to-buf/stargazers","contributors_url":"https://api.github.com/repos/node-modules/stream-to-buf/contributors","subscribers_url":"https://api.github.com/repos/node-modules/stream-to-buf/subscribers","subscription_url":"https://api.github.com/repos/node-modules/stream-to-buf/subscription","commits_url":"https://api.github.com/repos/node-modules/stream-to-buf/commits{/sha}","git_commits_url":"https://api.github.com/repos/node-modules/stream-to-buf/git/commits{/sha}","comments_url":"https://api.github.com/repos/node-modules/stream-to-buf/comments{/number}","issue_comment_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues/comments{/number}","contents_url":"https://api.github.com/repos/node-modules/stream-to-buf/contents/{+path}","compare_url":"https://api.github.com/repos/node-modules/stream-to-buf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/node-modules/stream-to-buf/merges","archive_url":"https://api.github.com/repos/node-modules/stream-to-buf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/node-modules/stream-to-buf/downloads","issues_url":"https://api.github.com/repos/node-modules/stream-to-buf/issues{/number}","pulls_url":"https://api.github.com/repos/node-modules/stream-to-buf/pulls{/number}","milestones_url":"https://api.github.com/repos/node-modules/stream-to-buf/milestones{/number}","notifications_url":"https://api.github.com/repos/node-modules/stream-to-buf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/node-modules/stream-to-buf/labels{/name}","releases_url":"https://api.github.com/repos/node-modules/stream-to-buf/releases{/id}","deployments_url":"https://api.github.com/repos/node-modules/stream-to-buf/deployments","created_at":"2018-02-28T03:13:50Z","updated_at":"2018-02-28T03:53:14Z","pushed_at":"2018-02-28T03:57:36Z","git_url":"git://github.com/node-modules/stream-to-buf.git","ssh_url":"git@github.com:node-modules/stream-to-buf.git","clone_url":"https://github.com/node-modules/stream-to-buf.git","svn_url":"https://github.com/node-modules/stream-to-buf","homepage":null,"size":0,"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/node-modules/stream-to-buf/pulls/1"},"html":{"href":"https://github.com/node-modules/stream-to-buf/pull/1"},"issue":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/issues/1"},"comments":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/node-modules/stream-to-buf/statuses/66a56d003aaeb46e48547f3f475f96a9a36dc2fb"}},"author_association":"OWNER"}}
{"actor":{"display_login":"popomore"}}