Skip to content

Commit

Permalink
test: replace forEach() test-stream-pipe-unpipe-stream.js
Browse files Browse the repository at this point in the history
test: fix lint error
  • Loading branch information
Dario Presutti authored and DevPres committed Nov 28, 2023
1 parent a628dda commit 3232fba
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions test/parallel/test-stream-pipe-unpipe-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const assert = require('assert');

const { Readable, Writable } = require('stream');

const source = Readable({ read: () => {} });
const dest1 = Writable({ write: () => {} });
const dest2 = Writable({ write: () => {} });
const source = Readable({ read: () => { } });
const dest1 = Writable({ write: () => { } });
const dest2 = Writable({ write: () => { } });

source.pipe(dest1);
source.pipe(dest2);
Expand Down Expand Up @@ -34,9 +34,9 @@ assert.strictEqual(source._readableState.pipes.length, 0);

{
// Test `cleanup()` if we unpipe all streams.
const source = Readable({ read: () => {} });
const dest1 = Writable({ write: () => {} });
const dest2 = Writable({ write: () => {} });
const source = Readable({ read: () => { } });
const dest1 = Writable({ write: () => { } });
const dest2 = Writable({ write: () => { } });

let destCount = 0;
const srcCheckEventNames = ['end', 'data'];
Expand All @@ -45,13 +45,12 @@ assert.strictEqual(source._readableState.pipes.length, 0);
const checkSrcCleanup = common.mustCall(() => {
assert.strictEqual(source._readableState.pipes.length, 0);
assert.strictEqual(source._readableState.flowing, false);

srcCheckEventNames.forEach((eventName) => {
for (let eventName of srcCheckEventNames) {

Check failure on line 48 in test/parallel/test-stream-pipe-unpipe-streams.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'eventName' is never reassigned. Use 'const' instead
assert.strictEqual(
source.listenerCount(eventName), 0,
`source's '${eventName}' event listeners not removed`
);
});
}
});

function checkDestCleanup(dest) {
Expand All @@ -65,13 +64,13 @@ assert.strictEqual(source._readableState.pipes.length, 0);
'listener which is `unpipeChecker`'
);
dest.removeListener('unpipe', unpipeChecker);
destCheckEventNames.forEach((eventName) => {
for (const eventName of destCheckEventNames) {
assert.strictEqual(
dest.listenerCount(eventName), 0,
`destination{${currentDestId}}'s '${eventName}' event ` +
'listeners not removed'
);
});
}

if (--destCount === 0)
checkSrcCleanup();
Expand All @@ -86,8 +85,8 @@ assert.strictEqual(source._readableState.pipes.length, 0);
}

{
const src = Readable({ read: () => {} });
const dst = Writable({ write: () => {} });
const src = Readable({ read: () => { } });
const dst = Writable({ write: () => { } });
src.pipe(dst);
src.on('resume', common.mustCall(() => {
src.on('pause', common.mustCall());
Expand Down

0 comments on commit 3232fba

Please sign in to comment.