Skip to content

Solving the subset sum problem question #83

Answered by lmammino
Ashilex asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Ashilex,

thanks for getting a copy of the book and for submitting this question.

Buffering might happen for a variety of reasons (OS, Node.js version, etc)

One way you can force the buffered data to be flushed on demand is to use the following pattern:

writableStream.cork() // starts to buffer all following writes into memory
writableStream.write('...')
writableStream.uncork() // forces a flush of all the buffered data to the underlying writable resource

So if we change the code as in the following screenshot (note lines 19 and 21), you should now see the expected behaviour:

You can find more info about writable.cork() and writable.uncork() in the official Node.js docs.

I hope thi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lmammino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants