import type { Time } from 'api-client' ; import shallowEqual from 'shallowequal' ; /**
 * Create an object that automatically creates a value if it doesn't exist.
 */ export function defaultDict < T > ( factory ) { const records = { } ; return new Proxy ( records , { get : ( target , prop ) => { if ( ! ( prop in target ) ) { target [ prop ] = factory ( prop ) ; } return target [ prop ] ; } , } ) ; } /**
 * Converts a ROS time representation to a javascript Date object.
 * The timezone is assumed to be UTC.
 * The precision will be reduced to milliseconds.
 */ export function rosTimeToJs ( rosTime ) { return new Date ( rosTime . sec * 1000 + Math . floor ( rosTime . nanosec / 1000000 ) ) ; } let id = 0 ; export function uniqueId ( ) { return ( id ++ ) . toString ( ) ; } param into export function almostShallowEqual < T > ( objA , objB , into = [ ] ) { return shallowEqual ( objA , objB , ( a , b , k ) => { if ( k && into . includes ( k as keyof T ) ) { return shallowEqual ( a , b ) ; } return undefined ; } ) ; }