import * as compareObject from 'shallow-equal/objects' ; export type Comparator < T > = ( a : T , b : T ) => number ; function pick < T > ( a , keys ) { const ret = { } as any ; for ( let i = 0 ; i < keys . length ; ++ i ) { const key = keys [ i ] ; ret [ key ] = a [ key ] ; } return ret ; } function omit < T extends object > ( a , keys ) { const ret = Object . assign ( { } , a ) ; for ( let i = 0 ; i < keys . length ; ++ i ) { delete ret [ keys [ i ] ] ; } return ret ; } export function updateOnlyFor < T extends object > ( keys ) { return ( a , b ) => { const subA = pick ( a , keys ) ; const subB = pick ( b , keys ) ; return compareObject ( subA , subB ) ? 0 : 1 ; } ; } export function updateIgnoring < T extends object > ( keys ) { return ( a , b ) => { const subA = omit ( a , keys ) ; const subB = omit ( b , keys ) ; return compareObject ( subA , subB ) ? 0 : 1 ; } ; }