# soct

> Proxy classes over socket.io.

Latest version **2.0.1** (published 2019-11-27) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2019-11-27 |
| First published | 2018-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 19.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jeremy Henson |
| Maintainers | jhenson29 |
| Keywords | socket, socket.io, soct, class, proxy, wrapper |

## Links

- npm: https://www.npmjs.com/package/soct
- Repository: https://github.com/jhenson29/node-soct
- Homepage: https://github.com/jhenson29/node-soct#readme
- Issues: https://github.com/jhenson29/node-soct/issues
- npm.io page: https://npm.io/package/soct

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^3.3.3
- [socket.io](https://npm.io/package/socket.io.md) ^2.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2019-11-27
- 1.1.2 — 2019-11-26
- 1.1.1 — 2018-12-02
- 1.0.5 — 2018-12-02
- 1.1.0 — 2018-12-02
- 1.0.4 — 2018-11-25
- 1.0.3 — 2018-11-25
- 1.0.2 — 2018-11-20
- 1.0.1 — 2018-11-20
- 1.0.0 — 2018-11-20

## README

<div align="center"><p>

<a href="https://github.com/jhenson29/node-soct/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg"/></a>

<a href="https://travis-ci.org/jhenson29/node-soct">
<img src="https://travis-ci.org/jhenson29/node-soct.svg?branch=master"/></a>

<a href="https://coveralls.io/github/jhenson29/node-soct?branch=master">
<img src="https://coveralls.io/repos/github/jhenson29/node-soct/badge.svg?branch=master"/></a>

<a href="https://snyk.io/test/github/jhenson29/node-soct?targetFile=package.json">
<img src="https://snyk.io/test/github/jhenson29/node-soct/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/jhenson29/node-soct?targetFile=package.json" style="max-width:100%;"></a>
</p></div>

# Node Soct

Proxy classes over socket.io.

## Version 2.x.x w/ TypeScript!

## Install

```javascript
npm i -s soct
```

## Getting Started

### Class to proxy

```javascript
// foo.js

class Foo {
    constructor() {
        this.state = {
            bar: true,
        };
    }

    get bar() {
        return this.state.bar;
    }
    set bar(val) {
        this.state.bar = val;
    }

    baz(val) {
        return val * 2;
    }
}

module.exports = Foo;
```

### New Foo Service

```javascript
//service.js

const {createSoctServer} = require("soct");
const Foo = require("./foo");

createSoctServer(
    new Foo(), // class to proxy; must be an instance of the class
    5000, // port to proxy on
);
```

### Use Foo Proxy

```javascript
// app.js

const {createSoctClient} = require("soct");
const Foo = require("./foo");

const foo = createSoctClient(
    Foo, // class definition
    5000, // port to proxy on (matches previous service)
);

const run = async () => {
    console.log(await foo.bar); // => true
    foo.bar = false;
    console.log(await foo.bar); // => false
    console.log(await foo.baz(5)); // => 10
};

run();
```

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