Skip to content

Commit

Permalink
zlib: refactored bytesRead test to use callbacks
Browse files Browse the repository at this point in the history
Refactored bytesRead test to use callbacks instead of timers

Refs: nodejs#8874
  • Loading branch information
AlexanderOMara committed May 24, 2017
1 parent df6c1f0 commit cf58570
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/parallel/test-zlib-bytes-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ const expectBuf = Buffer.from(expectStr);
function createWriter(target, buffer) {
const writer = { size: 0 };
const write = () => {
target.write(Buffer.from([buffer[writer.size++]]));
if (writer.size < buffer.length) {
setTimeout(write, 25);
} else {
target.end();
}
target.write(Buffer.from([buffer[writer.size++]]), () => {
if (writer.size < buffer.length) {
target.flush(write);
} else {
target.end();
}
});
};
write();
return writer;
Expand Down

0 comments on commit cf58570

Please sign in to comment.