# fork-acknowledge

> Get acknowledgements back from messages sent to forked processes

Latest version **0.2.0** (published 2018-11-20) · 0 weekly downloads

## Install

```sh
npm install fork-acknowledge
pnpm add fork-acknowledge
yarn add fork-acknowledge
bun add fork-acknowledge
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-11-20 |
| First published | 2018-11-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | laggingreflex |

## Links

- npm: https://www.npmjs.com/package/fork-acknowledge
- Repository: https://github.com/laggingreflex/fork-acknowledge
- Homepage: https://github.com/laggingreflex/fork-acknowledge#readme
- Issues: https://github.com/laggingreflex/fork-acknowledge/issues
- npm.io page: https://npm.io/package/fork-acknowledge

## Recent versions

- 0.2.0 (latest) — 2018-11-20
- 0.1.1 — 2018-11-20
- 0.1.0 — 2018-11-20

## README

# fork-acknowledge

Get acknowledgements back from messages sent to forked processes

## Install

```
npm i fork-acknowledge
```

## Usage

* **`parent`**

  ```js
  const { fork } = require('child_process')
  const fack = require('fork-acknowledge')

  const child = fork(...);
  const { send } = fack(child);

  const result = await send('message');
          └────────────────────────────────────────┐
  ```

* **`child`**

  ```js
  const fack = require('fork-acknowledge')         │
                                                   │
  const { on } = fack(process);                    │
                                                   │
  on(async message => {                            │
    return 'result' ───────────────────────────────┘
  });
  ```

### API

```js
const {send, on} = fack(process)
```

* **`process`** `[process]` - [process], or a ([forked]) [child_process] used to send, or on which to listen for, messages.

* **`send`** `[function]` - Function to send messages to **`process`**

  ```js
  const promise = send(...args)
  ```

  * **`promise`** `[promise]` - Resolves (or rejects) when the corresponding¹ **`on`** method on the **`process`** returns (or throws).
  * **`promise.off`** `[function]` - Special function attached to the promise, to remove the `process.on()` event listener created by **`send`**, which otherwise is automatically removed upon the **`promise`**'s resolution/rejection.
  * **`args`** `[array]` - Message arguments to be sent.

* **`on`** `[function]` - Function to receive messages from **`process`**

  ```js
  const off = on(fn)
  ```

  * **`off`** `[function]` - Function to remove the event listener after which **`fn`** will no longer be called.
  * **`fn`** `[function]` - Function that gets called when a message is received. It's the return value (or error in case it throws) of this function that's used to resolve or reject the corresponding¹ **`promise`**. Correspondence is maintained by sending/receiving a unique id (generated using [crypto]).

[child_process]: https://nodejs.org/api/child_process.html
[forked]: https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
[process]: https://nodejs.org/api/process.html
[crypto]: https://nodejs.org/api/crypto.html

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