Skip to content
Myr

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 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–12why, one step back
6
7// 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 subprocess

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 13–27why, one step back
13export 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 back
28
29// Retrieve the `ipc` shared by both the current process and the subprocess

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

lines 30–32why, one step back
30const getIpcMethods = (anyProcess, isSubprocess, ipc) => ({
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–49why, 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,48 }),49});