Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move internal handlers to promises, add finished #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mafintosh
Copy link
Owner

wip (will be a major bump if it lands)

moves ._write, ._read, ._final etc to promises instead of cbs.
does some tricks to avoid ticks when streams are sync to get that perf :)

missing test migration and transform streams still

@@ -317,7 +321,9 @@ class ReadableState {

while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
stream._duplexState |= READ_ACTIVE_AND_SYNC_AND_NEEDS_PUSH
stream._read(this.afterRead)
const p = stream._read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callPromise(this, stream.read(), this.afterRead, this.afterReadError) ?

@@ -165,7 +166,9 @@ class WritableState {
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
const data = this.shift()
stream._duplexState |= WRITE_ACTIVE_AND_SYNC
stream._write(data, this.afterWrite)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callPromise(this, stream._write(data), this.afterWrite, this.afterWriteError) ?

@@ -890,6 +914,37 @@ function pipelinePromise (...streams) {
})
}

function finished (stream) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be in a different PR? Seems to be usable immediately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants