export const normalize = < T > ( arr = [ ] , k ) => { const ids = [ ] ; const byId = arr . reduce < Record < string , T > > ( ( prev , curr ) => { prev [ curr [ k ] ] = curr ; ids . push ( curr [ k ] ) ; return prev ; } , { } ) ; return { ids , byId } ; } ;