# bridle

> Javscript black magic RPC over websockets.

Latest version **1.0.2** (published 2018-04-24) · ISC license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2018-04-24 |
| First published | 2017-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 4 |
| Unpacked size | 810.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Forest Beaver |
| Maintainers | lexe |
| Keywords | RPC, Bridle |

## Links

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

## Dependencies (4)

- [ws](https://npm.io/package/ws.md) ^3.3.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [bufferutil](https://npm.io/package/bufferutil.md) ^3.0.3
- [reconnecting-websocket](https://npm.io/package/reconnecting-websocket.md) ^3.2.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-04-24
- 1.0.1 — 2017-12-23
- 1.0.0 — 2017-12-23
- 0.0.6 — 2017-12-23
- 0.0.5 — 2017-12-23
- 0.0.4 — 2017-12-22
- 0.0.3 — 2017-12-22
- 0.0.2 — 2017-12-22
- 0.0.1 — 2017-12-22

## README

Bridle: Black magic Javascript RPC
==================================
[![Version npm](https://img.shields.io/npm/v/bridle.svg)](https://www.npmjs.com/package/bridle)
[![Linux Build](https://img.shields.io/travis/lexe11/bridle/master.svg)](https://travis-ci.org/lexe11/bridle)
[![Coverage Status](https://img.shields.io/coveralls/lexe11/bridle/master.svg)](https://coveralls.io/r/lexe11/bridle?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/lexe11/bridle/badge.svg)](https://snyk.io/test/github/lexe11/bridle)
[![License](https://img.shields.io/npm/l/bridle.svg)](https://snyk.io/test/github/lexe11/bridle)

## Installation
```
npm install --save bridle
```
Bridle allows exporting functions from a Node.js server and then calling
them natively from a client (both Node and browsers are supported).

Remote functions will be ran on the server, with communication occurring
using
[`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
transport. Local functions will be ran natively on the client as is.

**Note:** This project exists because it can, not because it should. The
author takes no responsibility for any \[mis\]use.

## Usage

### Server:
```js
const Bridle = require('bridle');

new Bridle.Server({
    port: 7777,
    localFunctions: {
        foo: () => {
            console.log('bar');
        }
    },
    remoteFunctions: {
        hello: (name) => 'Hello ' + name
    }
});
```

### Client:
```js
import {Client} from 'bridle';

const rpc = new Client();

rpc.connect('ws://localhost:7777')

    .then(functions => {

        functions.foo();

        functions.hello('world!').then(result => {
            console.log(result);
        }).catch(error => {
            console.log(error);
        });
    });
```

**Output:**

```
$ bar
$ Hello world!
```


## Support
Tested in Node.js v6.10.0, Chrome 63

## License

ISC

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