ilp-protocol-ccp
Version:
Implementation of the Connector-to-Connector Protocol (CCP)
17 lines • 653 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeUuid = exports.readUuid = void 0;
const readUuid = (reader) => {
const unformattedUuid = reader.read(16).toString('hex');
return unformattedUuid.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '$1-$2-$3-$4-$5');
};
exports.readUuid = readUuid;
const writeUuid = (writer, uuid) => {
const uuidBuffer = Buffer.from(uuid.replace(/-/g, ''), 'hex');
if (uuidBuffer.length !== 16) {
throw new Error('tried to write invalid UUID. value=' + uuid);
}
writer.write(uuidBuffer);
};
exports.writeUuid = writeUuid;
//# sourceMappingURL=uuid.js.map