Conversation
done(); | ||
} | ||
|
||
function done() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个要 once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promise 只会 resolve 一次,这个多次调用也无所谓的
index.js
Outdated
function done() { | ||
if (error) reject(error); | ||
else resolve(Buffer.concat(bufs)); | ||
cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
先 removeListener?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
先 cleanup 再返回
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
=======================================
Coverage ? 100%
=======================================
Files ? 1
Lines ? 29
Branches ? 0
=======================================
Hits ? 29
Misses ? 0
Partials ? 0
Continue to review full report at Codecov.
|
} | ||
|
||
function done() { | ||
cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放到前面了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额,这个还不能放前面,bufs 被清空了。问题不大,反正都是同步的。
index.js
Outdated
} | ||
|
||
function cleanup() { | ||
bufs = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bufs = null
index.js
Outdated
|
||
function cleanup() { | ||
bufs = []; | ||
error = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bufs 和 error 都不需要设置吧
"name": "stream-to-buf", | ||
"description": "convert stream to buffer", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/node-modules/stream-to-buf", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream-to-buffer 被抢。。。
No description provided.