UNPKG

@arturwojnar/hermes-postgresql

Version:

Production-Ready TypeScript Outbox Pattern for PostgreSQL

15 lines 568 B
const LSN_REGEXP = new RegExp(`[0-9a-f]+/[0-9a-f]+`, 'i'); const convertLsnToBigInt = (lsn) => { const [upperWal, lowerWal] = lsn.split('/').map((x) => parseInt(x, 16)); return (BigInt(upperWal) << 32n) | BigInt(lowerWal); }; const constructLsn = (upperWal, lowerWal) => `${upperWal}/${lowerWal}`; const isLsn = (value) => LSN_REGEXP.test(value); const toLsn = (value) => { if (isLsn(value)) { return value; } throw new Error(`not LSN ${value}`); }; export { constructLsn, convertLsnToBigInt, isLsn, toLsn }; //# sourceMappingURL=lsn.js.map