fnbr
Version:
A library to interact with Epic Games' Fortnite HTTP and XMPP services
29 lines • 977 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class STOMPMessage {
constructor(data) {
this.command = data.command;
this.headers = data.headers;
this.body = data.body;
}
toString() {
return `${this.command}\n${Object.entries(this.headers).map(([k, v]) => `${k}:${v}`).join('\n')}\n\n${this.body || ''}\x00`;
}
static fromString(message) {
const [header, body] = message.split('\n\n');
const [command, ...rawHeaders] = header.split('\n');
const headers = {};
rawHeaders.forEach((h) => {
const [key, ...value] = h.split(':');
headers[key] = value.join(':');
});
return new STOMPMessage({
command,
headers,
// eslint-disable-next-line no-control-regex
body: body.replace(/\x00$/, ''),
});
}
}
exports.default = STOMPMessage;
//# sourceMappingURL=STOMPMessage.js.map