ipc-iterate-twice.js
This file
Path
test/fixtures/ipc-iterate-twice.js
17 lines · 592 bytes · JavaScript
Last changed by
Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
History of this fileTake it
Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 1–5why, one step back1#!/usr/bin/env node2import {sendMessage, getEachMessage} from '../../index.js';3import {foobarString} from '../helpers/input.js';45for (let index = 0; index < 2; index += 1) {Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
lines 6–7why, one step back6 // Intentionally not awaiting `sendMessage()` to avoid a race condition7 sendMessage(foobarString);Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 8–10why, one step back8 // eslint-disable-next-line no-await-in-loop9 for await (const message of getEachMessage()) {10 if (message === foobarString) {Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 11why, one step back11 // eslint-disable-next-line unicorn/no-break-in-nested-loop -- breaks only the inner loop, the outer loop must continueAdd promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 12–14why, one step back12 break;13 }14Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a
line 15why, one step back15 await sendMessage(`${index}${message}`);Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 16–17why, one step back16 }17}