Skip to content
Myr

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 file

Take it

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 1–5why, one step back
1#!/usr/bin/env node
2import {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 back
6 // Intentionally not awaiting `sendMessage()` to avoid a race condition
7 sendMessage(foobarString);

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 8–10why, one step back
8 // eslint-disable-next-line no-await-in-loop
9 for await (const message of getEachMessage()) {10 if (message === foobarString) {

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 11why, one step back
11 // eslint-disable-next-line unicorn/no-break-in-nested-loop -- breaks only the inner loop, the outer loop must continue

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 12–14why, one step back
12 break;
13 }14

Do not disconnect IPC on `error` event on process (#1086)ehmickybefore adoptiond6f5d9a

line 15why, one step back
15 await sendMessage(`${index}${message}`);

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 16–17why, one step back
16 }
17}