# ambassador

> Ambassador provides a way to communicate between node.js processes.

Latest version **0.1.3** (published 2013-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install ambassador
pnpm add ambassador
yarn add ambassador
bun add ambassador
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2013-09-26 |
| First published | 2013-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | kael |
| Maintainers | kael |
| Keywords | inter-process, process, communicator, message, signal, kill |

## Links

- npm: https://www.npmjs.com/package/ambassador
- Repository: https://github.com/kaelzhang/ambassador
- Issues: https://github.com/kaelzhang/ambassador/issues
- npm.io page: https://npm.io/package/ambassador

## Dependencies (3)

- [lockup](https://npm.io/package/lockup.md) ~0.1.0
- [fs-sync](https://npm.io/package/fs-sync.md) ~0.2.2
- [code-this](https://npm.io/package/code-this.md) ~0.1.2

## Recent versions

- 0.1.3 (latest) — 2013-09-26
- 0.1.2 — 2013-09-03
- 0.1.1 — 2013-08-23

## README

# Ambassador

Ambassador provides a way to communicate between node.js processes.

With ambassador:

- You could send JavaScript object(or other types of variables) between processes
- You could safely kill a process which also contains ambassador.

## Installation

	npm install ambassador --save
	
## Usage

First of all, `ambassador` is an [`EventEmitter`](http://nodejs.org/api/events.html#events_class_events_eventemitter).

### Example

Process A (pid: 14100)

```js
// Listen to signal 'watch'
require('ambassador').on('watch', function(pid, data){
	console.log('Signal "watch" from process[', pid, '] with data', data);
});

// So that process A will hang on.
require('http').createServer(function(){}).listen(9876);
```

Process B (pid: 14102)

```js
// Send data to process 14100 (A)
require('ambassador').send(14100, 'watch', {
	abc: 1
});
```

Then, process A will print:

	Signal "watch" from process[ 14102 ] with data {abc: 1}
	

## Methods

### ambassador.send(pid, signal, data);

Send a `signal` signal to the process `pid` with data `data`

##### Returns `ambassador`

##### pid `Number`

The pid of the target process

##### signal `String`

Signal name

##### data `mixed`

The data to be sent


### ambassador.on(signal, callback)

##### Returns `ambassador`

##### signal `String`

##### callback `function(pid, data)`

The callback function

##### pid `Number`

The pid number from which process the signal has been sent.

##### data `mixed`

The received data


### ambassador.kill(pid)

If the target process contains `ambassador`, this method will safely kill that process.

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