import { Window } from 'happy-dom' ; /**
 *
 */ export default class GlobalRegistrator { private static registered = [ ] ; /**
     * Registers Happy DOM globally.
     */ public static register ( ) { if ( this . registered . length ) { throw new Error ( 'Failed to registered. Happy DOM has already been globally registered.' ) ; } const window = new Window ( ) ; for ( const key of Object . keys ( window ) ) { if ( global [ key ] === undefined && key !== 'undefined' ) { global [ key ] = window [ key ] ; this . registered . push ( key ) ; } } } /**
     * Registers Happy DOM globally.
     */ public static unregister ( ) { if ( this . registered . length ) { throw new Error ( 'Failed to unregistered. Happy DOM has not previously been globally registered.' ) ; } for ( const key of this . registered ) { delete global [ key ] ; } } }