# sb-communication

> A communication library for communication libraries

Latest version **5.0.0** (published 2018-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install sb-communication
pnpm add sb-communication
yarn add sb-communication
bun add sb-communication
```

## 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 | 5.0.0 |
| Published | 2018-05-06 |
| First published | 2015-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | steelbrain |
| Maintainers | steelbrain |

## Links

- npm: https://www.npmjs.com/package/sb-communication
- Repository: https://github.com/steelbrain/communication
- Homepage: https://github.com/steelbrain/communication#readme
- Issues: https://github.com/steelbrain/communication/issues
- npm.io page: https://npm.io/package/sb-communication

## Recent versions

- 5.0.0 (latest) — 2018-05-06
- 4.0.1 — 2015-12-04
- 4.0.0 — 2015-12-03
- 3.1.0 — 2015-08-24
- 3.0.0 — 2015-08-22
- 2.0.2 — 2015-08-22
- 2.0.1 — 2015-08-22
- 2.0.0 — 2015-08-22
- 1.0.0 — 2015-08-22
- 0.0.1 — 2015-08-22

## README

SB-Communication
================

SB-Communication is a base communication low-level library meant to be used in other communication libraries.
It allows promise-based communication on both ends, You must write a wrapper for it for your use-case specific
stream, socket or resource though. It works in both browsers and node!

#### Example Communication Implementation

```js
'use babel'

import Communication from 'sb-communication'

const worker = new WebWorker('worker.js')

const communication = new Communication({
  listener(callback) {
    worker.onmessage = callback
  },
  send(data) {
    worker.postMessage = data
  },
})

// Event-Specific bindings
communication.on('count-pi', async function(data) {
  // ^ Handlers can return Promises or be sync
  console.log(data)
  return 'Something else'
})
```

#### API

```js
export default class Communication {
  constructor({ listener: Function, send: Function })
  on(event, callback)
  send(event, payload)
  dispose()
}
```

#### LICENSE

This project is licensed under the terms of MIT License.

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