import dayjs from 'dayjs' ; export const sleep = async ( ms ) : Promise < void > => await new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; export function debounce < Params extends any [ ] > ( func , timeout ) { let timer ; return ( ... args ) => { clearTimeout ( timer ) ; timer = setTimeout ( ( ) => { func ( ... args ) ; } , timeout ) ; return timer ; } ; } export function throttle ( fn , wait ) { let time = Date . now ( ) ; return function ( ) { if ( time + wait - Date . now ( ) < 0 ) { fn ( ) ; time = Date . now ( ) ; } } ; } const TIME_FORMAT_CN = 'YYYY-MM-DD, HH:mm:ss' ; const TIME_FORMAT_EN = 'MMM DD, YYYY HH:mm:ss' ; export function formatTime ( timestamp , lang , skipNumber = false , options ? ) { return dayjs ( skipNumber ? timestamp : Number ( timestamp + '000' ) ) . format ( options ?. template || ( lang !== 'en' ? TIME_FORMAT_CN : TIME_FORMAT_EN ) ) ; }