export function dedupe < T > ( arr ) { return arr . filter ( ( value , index , self ) => self . indexOf ( value ) === index ) ; } export function dedupeBy < T > ( arr , transform ) { return arr . filter ( ( value , index , self ) => self . map ( transform ) . indexOf ( transform ( value ) ) === index ) ; } export function ensureArray < T > ( value ) { return Array . isArray ( value ) ? value : [ value ] ; } export function flatten < T > ( arrays ) { return [ ] . concat . apply ( [ ] , arrays ) ; } export function equal ( a , b ) { if ( a === b ) return true ; if ( a . length !== b . length ) return false ; let aSorted = a . concat ( ) . sort ( ) ; let bSorted = b . concat ( ) . sort ( ) ; for ( let i = 0 ; i < aSorted . length ; ++ i ) { if ( aSorted [ i ] !== bSorted [ i ] ) return false ; } return true ; } export function equalExact ( a , b ) { if ( a === b ) return true ; if ( a . length !== b . length ) return false ; for ( let i = 0 ; i < a . length ; ++ i ) { if ( a [ i ] !== b [ i ] ) return false ; } return true ; }