import { UUID } from 'polar-shared/src/metadata/UUID' ; import { Sequence , Sequences } from '../util/Sequences' ; export namespace UUIDs { export function create ( ) { return Sequences . create ( ) ; } export function parse ( sequence ) { return Sequences . parse ( sequence ) ; } export function toNonce ( sequence ) { return parse ( sequence ) ?. nonce ; } /**
     * Format the UUID as a string
     */ export function format ( uuid ) { if ( uuid === undefined ) { return 'undefined' ; } const seq = parse ( uuid ) ; return `${ uuid } (nonce=${ seq ?. nonce })` ; } Deprecated export function compare ( u0 ? , u1 ? ) { if ( u0 === undefined && u1 !== undefined ) { return - 1 ; } if ( u0 === undefined && u1 === undefined ) { return 0 ; } if ( u0 !== undefined && u1 === undefined ) { return 1 ; } return cmp ( u0 ! , u1 ! ) ; } export function compare2 ( u0 ? , u1 ? ) { if ( u0 === undefined && u1 !== undefined ) { return - 1 ; } if ( u0 === undefined && u1 === undefined ) { return 0 ; } if ( u0 !== undefined && u1 === undefined ) { return 1 ; } return cmp2 ( u0 ! , u1 ! ) ; } VisibleForTesting Deprecated export function cmp ( s0 , s1 ) { return s0 ! . localeCompare ( s1 ! , "en-us" ) ; } /**
     * Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first
     * argument is less than, equal to, or greater than the second.
     */ export function cmp2 ( s0 , s1 ) { return s1 ! . localeCompare ( s0 ! , "en-us" ) ; } /**
     * Return true if the 'comparison' UUID is updated later than the existing
     * UUID.
     */ export function isUpdated ( existing ? , comparison ? ) { return compare ( existing , comparison ) < 0 ; } }