export async function play ( player ) { try { await player . play ( ) ; return true ; } catch { player . muted = true ; await player . play ( ) ; return false ; } } export const delay = ( ms ) => new Promise ( ( resolve ) => window . setTimeout ( resolve , ms ) ) ; export class ChangedMap { map = new Map < string , any > ( ) ; changed ( tag , value ) { if ( ! this . map . has ( tag ) || ! isEqual ( this . map . get ( tag ) , value ) ) { this . map . set ( tag , value ) ; return true ; } else { return false ; } } clear ( ) { this . map . clear ( ) ; } } function isEqual ( a , b ) { if ( a === b ) return true ; if ( Array . isArray ( a ) ) return a . every ( ( x , i ) => isEqual ( x , b [ i ] ) ) ; return false ; } export function doubleRAF ( callback ) { window . requestAnimationFrame ( ( ) => { window . requestAnimationFrame ( callback ) ; } ) ; }