New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

child-ipc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

child-ipc

A typed, Electron-style IPC interface to facilitate communication between the main process and a child process in Node.js (including, but not limited to, Electron apps).

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Child IPC

A typed, Electron-style IPC interface to facilitate communication between the main process and a child process in Node.js (including, but not limited to, Electron apps).

Installation

npm install child-ipc --save

Example

main.ts

import { ChildIpc } from 'child-ipc';

import type { ChildIpcActions } from './child';

export interface MainIpcActions { }

const cp = fork(path.join(__dirname, 'child.js'), ['args'], { stdio: 'pipe' });
const ipc = new ChildIpc<MainIpcActions, ChildIpcActions>(cp);

async function processData(data: string): Promise<string> {
  const processed = await ipc.invoke('processData', data);
  // ...
  return processed;
}

child.ts

import { ChildIpc } from 'child-ipc';

import type { MainIpcActions } from './main';

export interface ChildIpcActions {
  commands: {
    'processData': { params: [data: string], returnVal: string }
  }
}

const ipc = new ChildIpc<ChildIpcActions, MainIpcActions>(process);

ipc.handle('processData', (e, data: string) => {
  // ...
  return processed;
});

Documentation

  • Tutorial
  • API

Keywords

ipc

FAQs

Package last updated on 19 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts