export function getRandomInt ( max ) { return Math . floor ( Math . random ( ) * Math . floor ( max ) ) ; } export function getRandom < T > ( array ) { return array [ getRandomInt ( array . length ) ] ; } export function getRandomElements < T > ( limit , array ) { if ( array . length <= limit ) { return array ; } const result = [ ] ; while ( result . length < limit ) { const i = getRandomInt ( array . length ) ; const temp = array [ i ] ; if ( result . indexOf ( temp ) === - 1 ) { result . push ( temp ) ; } } return result ; } export const compose = ( ... fns ) : any => { return fns . reduceRight ( ( prevFn , nextFn ) => ( ... args ) => nextFn ( prevFn ( ... args ) ) , value => value ) ; } ; export const isEqualMaps = ( map1 , map2 ) => { let testVal ; if ( map1 . size !== map2 . size ) { return false ; } for ( let [ key , val ] of map1 ) { testVal = map2 . get ( key ) ; if ( testVal !== val || ( testVal === undefined && ! map2 . has ( key ) ) ) { return false ; } } return true ; } ; export const IPRegExp = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ ;