import * as randomBytes from 'randombytes' ; const sanitize = require ( 'sanitize-filename' ) ; export type AnyFunction = ( ... args : any ) => any ; returns export function sanitizeFilename ( filename ) { const newFilename = sanitize ( filename , { replacement : ( ( invalidChar ) => { switch ( invalidChar ) { case '<' : return '❮' ; case '>' : return '❯' ; case ':' : return '꞉' ; case '"' : return "'" ; case '/' : return '／' ; case '\\' : return '⧵' ; case '|' : return '⏐' ; case '?' : return '？' ; case '*' : return '⁎' ; default : return '_' ; } } ) } ) ; return ( newFilename == '' ? randomBytes ( 5 ) . toString ( 'hex' ) : newFilename ) ; } returns export function lower ( text ) { return text . toLowerCase ( ) ; } /**
 * Converts `val` from the range (`fromStart`, `fromEnd`) to the range (`toStart`, `toEnd`).
 */ export function interpolate ( val , fromStart , fromEnd , toStart , toEnd ) { return ( ( val - fromStart ) / ( fromEnd - fromStart ) ) * ( toEnd - toStart ) + toStart ; } returns export function groupBy < T > ( objectList , ... keys ) { const results = [ ] ; for ( const object of objectList ) { const matchingGroup = results . find ( result => keys . every ( key => result [ 0 ] [ key ] == object [ key ] ) ) ; if ( matchingGroup != undefined ) { matchingGroup . push ( object ) ; } else { results . push ( [ object ] ) ; } } return results ; }