import fs from 'fs' ; import GroupPost from '../models/groupPost' ; export function generateFacebookGroupURLById ( id ) { return `https://www.facebook.com/groups/${ id }/` ; } namespace param { type } fileName return { Object [ ] } export function getOldPublications ( fileName ) { let allPublicationsList ; if ( fs . existsSync ( fileName ) ) { allPublicationsList = JSON . parse ( fs . readFileSync ( fileName , { encoding : 'utf8' } ) ) ; } else { allPublicationsList = [ ] ; } return allPublicationsList ; } param duration export async function sleep ( duration ) { return new Promise ( ( ( resolve ) => { setTimeout ( resolve , duration ) ; } ) ) ; } /**
 * Function automatically infinite scrolls
 */ export function autoScroll ( ) { const internalSleep = async ( duration ) : Promise < void > => new Promise ( ( ( resolve ) => { setTimeout ( resolve , duration ) ; } ) ) ; const scroll = async ( ) => { window . scrollBy ( 0 , document . body . scrollHeight ) ; await internalSleep ( Math . round ( ( Math . random ( ) * 4000 ) + 1000 ) ) ; scroll ( ) ; } ; scroll ( ) ; }