Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 38x 38x 1x 1x 1x 1x 1x 1x 9x 9x 1x 1x 1x 9x 9x 9x 9x 9x | import crypto from 'node:crypto';
/** Convert a UUID string to a BINARY(16) Buffer for MySQL. */
export function uuidBuf(uuid: string): Buffer {
return Buffer.from(uuid.replace(/-/g, ''), 'hex');
}
/** Read a BINARY(16) value from MySQL and return a hex UUID string. */
export function bufToUuid(buf: Buffer | string): string {
if (typeof buf === 'string') return buf;
const hex = buf.toString('hex');
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}
/** Generate a random UUID v4 string. */
export function newUuid(): string {
return crypto.randomUUID();
}
/** Split a comma-separated string of names, trimming whitespace and filtering empty entries. */
export function splitNames(value: string): string[] {
return value
.split(',')
.map(s => s.trim())
.filter(Boolean);
}
|