UNPKG

node-jet

Version:

Jet Realtime Message Bus for the Web. Daemon and Peer implementation.

28 lines (27 loc) 688 B
import { EventEmitter } from '../../1_socket/index.js'; /** * A method is a path that can be called. The peer.call method can be used to call methods */ export class Method extends EventEmitter { _path; _writeGroup; constructor(path, writeGroup = '') { super(); this._path = path; this._writeGroup = writeGroup; } path = () => this._path; call = (args) => { this.emit('call', args); }; toJson = () => { const params = { path: this._path }; if (this._writeGroup) { params.access = { write: this._writeGroup }; } return params; }; } export default Method;