export type Path = Array < string | number > ; export const serializePath = ( path ) : string => { return path . join ( ' ' ) ; } ; const numberOrString = ( segment ) : string | number => { const v = parseInt ( segment , 10 ) ; if ( isNaN ( v ) ) { return segment ; } return v ; } ; export const deserializePath = ( path ) : Path => { return path . split ( / / ) . map ( numberOrString ) ; } ; export const deserializeChangePath = ( path ) : Path => { return path . split ( /\/| / ) . map ( numberOrString ) ; } ;