Files
node/test/parallel/test-debugger-pid.js
Phillip Markert 86c871eced test: replace forEach() with for...of in parallel tests
Replace `Array.prototype.forEach()` with `for...of` loops across 17
tests in `test/parallel`, so each loop body reads as a plain statement
rather than an arrow callback.

None of the iterated values are sparse arrays, the one case where
`forEach` and `for...of` genuinely differ, so both constructs visit the
same elements in the same order. No callback relied on `this`, an early
return, or async behaviour, and the number of assertions run in each
file is unchanged.

Signed-off-by: Phillip Markert <phillip@ephisys.com>
PR-URL: https://github.com/nodejs/node/pull/65272
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-08-15 21:59:44 +00:00

31 lines
799 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
if (common.isWindows)
common.skip('unsupported function on windows');
const assert = require('assert');
const spawn = require('child_process').spawn;
let buffer = '';
// Connect to debug agent
const interfacer = spawn(process.execPath, ['inspect', '-p', '655555']);
interfacer.stdout.setEncoding('utf-8');
interfacer.stderr.setEncoding('utf-8');
const onData = (data) => {
data = (buffer + data).split('\n');
buffer = data.pop();
for (const line of data) {
interfacer.emit('line', line);
}
};
interfacer.stdout.on('data', onData);
interfacer.stderr.on('data', onData);
interfacer.on('line', common.mustCall((line) => {
assert.strictEqual(line, 'Target process: 655555 doesn\'t exist.');
}));