Skip to content
Myr

methods.js

This file

Path

lib/ipc/methods.js

50 lines · 1.3 KiB · JavaScript

Last changed by

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

History of this file

Take it

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 1–4why, one step back
1import process from 'node:process';
2import {sendMessage} from './send.js';3import {getOneMessage} from './get-one.js';4import {getEachMessage} from './get-each.js';

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 5why, one step back
5import {getCancelSignal} from './graceful.js';

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 6–7why, one step back
6
7// Add promise-based IPC methods in current process

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 8–9why, one step back
8export const addIpcMethods = (target, subprocess, {ipc}) => {
9 Object.assign(target, getIpcMethods(subprocess, false, ipc, target));

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 10–12why, one step back
10};
1112// Get promise-based IPC in the subprocess

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 13–15why, one step back
13export const getIpcExport = () => {
14 const anyProcess = process;15 const isSubprocess = true;

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

line 16why, one step back
16 const isIpc = process.channel !== undefined;

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 17–18why, one step back
17
18 return {

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

line 19why, one step back
19 ...getIpcMethods(anyProcess, isSubprocess, isIpc),

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 20–23why, one step back
20 getCancelSignal: getCancelSignal.bind(undefined, {
21 anyProcess,22 channel: anyProcess.channel,23 isSubprocess,

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

line 24why, one step back
24 ipc: isIpc,

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 25–27why, one step back
25 }),
26 };27};

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 28–29why, one step back
28
29// Retrieve the `ipc` shared by both the current process and the subprocess

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 30why, one step back
30const getIpcMethods = (anyProcess, isSubprocess, ipc, waitProcess = anyProcess) => ({

Add tests for I/O errors during `sendMessage()` (#1095)ehmickybefore adoptionc6c66da

lines 31–32why, one step back
31 sendMessage: sendMessage.bind(undefined, {
32 anyProcess,

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 33why, one step back
33 channel: anyProcess.channel,

Add tests for I/O errors during `sendMessage()` (#1095)ehmickybefore adoptionc6c66da

lines 34–47why, one step back
34 isSubprocess,
35 ipc,36 }),37 getOneMessage: getOneMessage.bind(undefined, {38 anyProcess,39 channel: anyProcess.channel,40 isSubprocess,41 ipc,42 }),43 getEachMessage: getEachMessage.bind(undefined, {44 anyProcess,45 channel: anyProcess.channel,46 isSubprocess,47 ipc,

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

line 48why, one step back
48 waitProcess,

Add tests for I/O errors during `sendMessage()` (#1095)ehmickybefore adoptionc6c66da

lines 49–50why, one step back
49 }),
50});