const timeouts = new Map < string , number > ( ) ; param cb param ms param id export function debounce ( cb , ms , id ) { const timeout = timeouts . get ( id ) ; if ( timeout != null ) { window . clearTimeout ( timeout ) ; } timeouts . set ( id , window . setTimeout ( ( ) => { cb ( ) ; timeouts . delete ( id ) ; } , ms ) ) ; }