ipc-iterate-back-serial.js
This file
Path
test/fixtures/ipc-iterate-back-serial.js
24 lines · 752 bytes · JavaScript
Last changed by
Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
History of this fileTake it
12345678910111213141516171819202122232425#!/usr/bin/env nodeimport process from 'node:process';import {sendMessage, getOneMessage} from '../../index.js';import {PARALLEL_COUNT} from '../helpers/parallel.js';import {isAlwaysTrue, getFirst} from '../helpers/ipc.js';
const filter = process.argv[2] === 'true' ? isAlwaysTrue : undefined;
await sendMessage(await getOneMessage({filter}));
const promise = sendMessage(1);process.emit('message', '.');await promise;
const messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 2);for (const message of messages) { // eslint-disable-next-line no-await-in-loop await sendMessage(message);}
const secondPromise = process.argv[3] === 'true' ? getFirst() : getOneMessage({filter});await sendMessage(await secondPromise);