mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 04:01:46 +03:00
168e222fcc
- Closes #8077 # Important Notes Tests are still WIP
13 lines
517 B
TypeScript
13 lines
517 B
TypeScript
import type { Uuid } from './yjsModel'
|
|
|
|
export function uuidFromBits(leastSigBits: bigint, mostSigBits: bigint): Uuid {
|
|
const bits = (mostSigBits << 64n) | leastSigBits
|
|
const string = bits.toString(16).padStart(32, '0')
|
|
return string.replace(/(........)(....)(....)(....)(............)/, '$1-$2-$3-$4-$5') as Uuid
|
|
}
|
|
|
|
export function uuidToBits(uuid: string): [leastSigBits: bigint, mostSigBits: bigint] {
|
|
const bits = BigInt('0x' + uuid.replace(/-/g, ''))
|
|
return [bits & 0xffffffffffffffffn, bits >> 64n]
|
|
}
|