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

ipc-pager

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipc-pager

fs-socketed ipc server/client/messenger

latest
npmnpm
Version
1.0.33
Version published
Maintainers
1
Created
Source

ipc-pager

Simple fs-socketed ipc handler with Server, Client and Messenger

Usage

Install with npm

npm i ipc-pager

Simple server example

//Define your socket handle
const HANDLE = '/tmp/pagetest.sock'

//Define your communication routing 
const ROUTES = {
    short : async ( data ) => {
        console.log('-short test-',data)
        return 'short result'
    },
    long : async ( data ) => {
        console.log('-long test-',data)
        await new Promise(end => setTimeout(end,5000))
        return 'long result'
    },
    longer : async ( data ) => {
        console.log('-long test-',data)
        await new Promise(end => setTimeout(end,10000))
        return 'long result'
    }
}

//Initialize a Server with handle and routing
const Pager = require('ipc-pager')
const server = Pager(HANDLE).Server(ROUTES)
server.start()
    .then(() => console.log(`Pager listening to ${HANDLE}`))

Simple messenger example

//Define your socket handle
const HANDLE = '/tmp/pagetest.sock'

//Initialize a messenger to handle
const Pager = require('ipc-pager')
const messenger = Pager(HANDLE).Messenger

//Send a message and log the resulting buffer
messenger({ action:'short', data:'Some test data' })
    .then(buf => console.log(buf.toString()))
    .catch(console.error)

Alternative return types

buffer (default)
//Send a message and log the resulting json
messenger({ action:'long', data:'Some test data' })
    .then(console.log)
    .catch(console.error)
json
//Send a message and log the resulting json
messenger({ action:'long', data:'Some test data' }, 'json')
    .then(console.log)
    .catch(console.error)
string
//Send a message and log the resulting string
messenger({ action:'longer', data:'Some test data' }, 'string')
    .then(console.log)
    .catch(console.error)

FAQs

Package last updated on 29 Nov 2019

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