# ipc-pager

> fs-socketed ipc server/client/messenger

Latest version **1.0.33** (published 2019-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install ipc-pager
pnpm add ipc-pager
yarn add ipc-pager
bun add ipc-pager
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.33 |
| Published | 2019-11-29 |
| First published | 2019-11-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | shittybill |
| Maintainers | r3volved |

## Links

- npm: https://www.npmjs.com/package/ipc-pager
- npm.io page: https://npm.io/package/ipc-pager

## Recent versions

- 1.0.33 (latest) — 2019-11-29
- 1.0.32 — 2019-11-29
- 1.0.31 — 2019-11-29
- 1.0.30 — 2019-11-28
- 1.0.29 — 2019-11-28
- 1.0.28 — 2019-11-28
- 1.0.27 — 2019-11-28
- 1.0.26 — 2019-11-28
- 1.0.25 — 2019-11-28
- 1.0.24 — 2019-11-28
- 1.0.23 — 2019-11-28
- 1.0.22 — 2019-11-28
- 1.0.21 — 2019-11-28
- 1.0.20 — 2019-11-28
- 1.0.19 — 2019-11-28
- … 19 more at https://npm.io/package/ipc-pager/versions

## README

# ipc-pager

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


## Usage

Install with npm

```
npm i ipc-pager
```

    
### Simple server example

```js    
//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

```js
//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)

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

##### json

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

##### string

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

---
_Source: https://npm.io/package/ipc-pager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
