@yesness/netclass
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

netclass

Proxy classes, objects, and functions over a network connection.

Installation

$ npm install @yesness/netclass

Usage

import NetClass from '@yesness/netclass';

// ===== SERVER SIDE =====
class Foo {
    static bar: string = 'hello';

    async getBar() {
        return bar;
    }

    async setBar(bar: string) {
        Foo.bar = bar;
    }
}

const server = NetClass.createServer({ object: Foo });
// On socket connection
server.connect(socket);

// ===== CLIENT SIDE =====
const client = NetClass.createClient(socket);
const ClientFoo = client.getObject();
console.log(await ClientFoo.getBar()); // 'hello'
await ClientFoo.setBar('goodbye');
console.log(await ClientFoo.getBar()); // 'goodbye'

More Examples

See the unit tests for more examples.

Package Sidebar

Install

npm i @yesness/netclass

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

178 kB

Total Files

25

Last publish

Collaborators

  • rcpooley