export function flatten < T > ( ... arrays ) { return Array . of < T > ( ) . concat ( ... arrays ) ; } export function definedOf < T > ( ... items ) { return items . filter ( ( i ) => i !== undefined ) . map ( ( i ) => i ! ) ; } declare global { interface Array < T > { choose < U > ( fn ) : U [ ] ; } } function choose < T , U > ( this , fn ) { return this . map ( fn ) . filter ( ( u ) => u !== undefined ) . map ( ( u ) => u ! ) ; } if ( ! Array . prototype . choose ) { Object . defineProperty ( Array . prototype , 'choose' , { enumerable : false , value : choose } ) ; }