import { AKSUID } from "./aksuid.js" ; import type { KSUIDOpts } from "./api.js" ; export class KSUID64 extends AKSUID { constructor ( opts ? ) { super ( 8 , { epoch : 1600000000000 , bytes : 12 , ... opts , } ) ; } timeOnlyBinary ( epoch = Date . now ( ) ) { const buf = new Uint8Array ( this . size ) ; const t = this . ensureTime ( epoch - this . epoch ) ; const h = ( t / 4294967296 ) >>> 0 ; const l = ( t & 4294967295 ) >>> 0 ; buf . set ( [ h >>> 24 , ( h >> 16 ) & 0xff , ( h >> 8 ) & 0xff , h & 0xff , l >>> 24 , ( l >> 16 ) & 0xff , ( l >> 8 ) & 0xff , l & 0xff , ] ) ; return buf ; } parse ( id ) { const buf = new Uint8Array ( this . size ) ; this . base . decodeBytes ( id , buf ) ; return { epoch : this . u32 ( buf ) * 4294967296 + this . u32 ( buf , 4 ) + this . epoch , id : buf . slice ( 8 ) , } ; } } param opts export const defKSUID64 = ( opts ? ) : KSUID64 => new KSUID64 ( opts ) ;