import fs from 'fs' ; import pify from 'pify' ; /**
 * stores the list of images inside public/images
 */ export class MapImageList { /**
     * builds the image list
     */ public static async build ( ) { this . files = ( await pify ( fs . readdir ) ( 'public/images/backgrounds' ) ) as string [ ] ; } returns public static getRandomFile ( ) { const index = Math . floor ( Math . random ( ) * this . files . length ) ; if ( index < 0 || index >= this . files . length ) { return null ; } return this . files [ index ] ; } public static getNumOfFiles ( ) { return this . files . length ; } private static files : string [ ] = [ ] ; }