npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ipc-portal

v1.8.0

Published

node portal, comunication between node apps

Downloads

9

Readme

IPC Portal

Node Inter Process Communication function based

a nodejs module for only local Inter Process Communication with full support for Linux, Mac and Windows. It also supports all forms of socket communication from low level unix and windows sockets to TCP sockets.

inspired by the library: node-ipc

A great solution for complex multiprocess Neural Networking in Node.JS

  • high performance
  • support access concurrency
  • super lightweight with only 1 file and no dependencies

get started:

npm i ipc-portal

using

  • Instance portal object setting application uniq name
  • And put functions sync or async or any values to another app can execute or get

example:

application A


/* Instance */
const Portal = required('ipc-portal')
const portal_in_a = new Portal('myApplicationNameA', {

  my_function_in_a(num1, num2){
    console.log('run function in app A')
    /* ... */
    return num1 + num2
  },

  async my_async_function_in_a(param1, param2, param3){
    console.log('run function async in app A')
    /* ... */
    return [ param1, param2, param3 ]
  },

  any_bool_value: true,
  any_object_value: { k: v },
  any_string_value: 'Lorem Ipsum'

  /* ... */

}, {
  log: true || console.log // Optional
})

/* Calling function in another app */
await portal_in_a.from('myApplicationNameB').my_function_in_b(attr1, attr2)

application B


/* Instance */
const Portal = required('ipc-portal')
const portal_in_b = new Portal('myApplicationNameB', {

  my_function_in_b(attr1, attr2){
    /* ... */
    console.log('run function in app B')
    return 'Ok'
  },
  
  /* ... */

})

/* Connect with app A */
let app_a = await portal_in_b.to('myApplicationNameA')

/* Call any function or get any value from application A */
let result = await app_a.my_function_in_a(10, 30)
let result2 = await app_a.my_async_function_in_a('item', 'col1', 'col2')
let { k } = await app_a.any_object_value

/* Check connection */
app_a.is_connected()

/* Reconnect */
await app_a.reconnect()

/* Connection events */
app_a.on('connect:myApplicationNameA', () => {})
app_a.on('disconnect:myApplicationNameA', () => {})
app_a.on('error:myApplicationNameA', () => {})
app_a.on('destroy:myApplicationNameA', () => {})

broadcasting

/* Instance app A */
const Portal = required('ipc-portal')
const portal_in_a = new Portal('myApplicationNameA', {
  /* ... */
})
/* Instance app B */
const Portal = required('ipc-portal')
const portal_in_b = new Portal('myApplicationNameB', {
  receive_broadcast(arg1, arg2){
    console.log('run function in app B')
    return 'Ok B'
  },
})
/* Connect to A */
portal_in_b.to('myApplicationNameA')
/* Instance app C */
const Portal = required('ipc-portal')
const portal_in_c = new Portal('myApplicationNameC', {
  receive_broadcast(arg1, arg2){
    console.log('run function in app C')
    return 'Ok C'
  },
})
/* Connect to A */
portal_in_c.to('myApplicationNameA')
/* In app A call broadcast for all app connecteds */
let result_broadcast = await portal_in_a.broadcast.receive_broadcast(value1, value2)

/* result is array if exists receive_broadcast in 2 or more */
let [ result_from_b, result_from_c ] = result_broadcast

working with buffer item in multi-level objects


let buffer = Buffer.from('my buffer text or any file...', 'utf-8')
let object_to_send = {
  v1: {
    v2: {
      a1: [
        a2: [ buffer ]
      ]
    }
  }
}

await portal.function_in_another_app(object_to_send)

setting new values or functions after instance

/* Instance app A */
const Portal = required('ipc-portal')
const portal = new Portal('myApplicationName', {
  /* ... */
})

portal.set('value_name', value)
/* Or */
portal.set(function myfunction(arg1, arg2){
  /* ... */
})