tsrpc-protocol
Version:
Base protocol for tsrpc
22 lines (21 loc) • 702 B
JavaScript
;
exports.__esModule = true;
var TsrpcPtl = /** @class */ (function () {
/**
*
* @param filename Protocol file path, always assign `__filename` to it.
* @param conf Custom protocol config, processed them later by yourself.
*/
function TsrpcPtl(filename, conf) {
if (conf === void 0) { conf = {}; }
this.filename = filename;
var nameMatch = filename.match(/Ptl(\w+)\.[jt]s/);
if (!nameMatch) {
throw new Error('Invalid protocol filename, must with prefix `Ptl`');
}
this.name = nameMatch[1];
this.conf = conf;
}
return TsrpcPtl;
}());
exports["default"] = TsrpcPtl;