methods.js
This file
Path
lib/ipc/methods.js
49 lines · 1.2 KiB · JavaScript
Last changed by
Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
History of this fileTake it
Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 1–4why, one step back1import 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 back5import {getCancelSignal} from './graceful.js';Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 6–12why, one step back67// Add promise-based IPC methods in current process8export const addIpcMethods = (subprocess, {ipc}) => {9 Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));10};1112// Get promise-based IPC in the subprocessAdd `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
lines 13–27why, one step back13export const getIpcExport = () => {14 const anyProcess = process;15 const isSubprocess = true;16 const ipc = process.channel !== undefined;1718 return {19 ...getIpcMethods(anyProcess, isSubprocess, ipc),20 getCancelSignal: getCancelSignal.bind(undefined, {21 anyProcess,22 channel: anyProcess.channel,23 isSubprocess,24 ipc,25 }),26 };27};Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68
lines 28–29why, one step back2829// Retrieve the `ipc` shared by both the current process and the subprocessAdd tests for I/O errors during `sendMessage()` (#1095)ehmickybefore adoptionc6c66da
lines 30–32why, one step back30const getIpcMethods = (anyProcess, isSubprocess, ipc) => ({31 sendMessage: sendMessage.bind(undefined, {32 anyProcess,Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 33why, one step back33 channel: anyProcess.channel,Add tests for I/O errors during `sendMessage()` (#1095)ehmickybefore adoptionc6c66da
lines 34–49why, one step back34 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,48 }),49});