export const pipe = < R > ( fn1 , ... fns ) : ( ( a : R ) => R ) => fns . reduce ( ( prevFn , nextFn ) => ( value ) => nextFn ( prevFn ( value ) ) , fn1 ) ; export const identity = < T > ( arg ) : T => arg ; export const mergeArrays = < T , U > ( array1 , array2 ) : Array < T | U > => { const jointArray = [ ... array1 , ... array2 ] . reverse ( ) ; const uniqueArray = jointArray . filter ( ( item , index ) => jointArray . indexOf ( item ) === index ) ; return uniqueArray . reverse ( ) ; } ; export const assertUnreachable = ( reason ) : never => { throw new Error ( `Unreachable code path: ${ reason }` ) ; } ; export const areArraysEqual = < T > ( array1 , array2 ) : boolean => { if ( array1 . length !== array2 . length ) { return false ; } const length = array1 . length ; for ( let index = 0 ; index < length ; index ++ ) { if ( array1 [ index ] !== array2 [ index ] ) { return false ; } } return true ; } ;