/**
 * Class that works around some insanity with the nodejs setTimeout API.
 */ import { DOM } from "polar-shared/src/util/DOM" ; export class Timeouts { public static setTimeout ( handler , timeout ) { if ( typeof window !== 'undefined' && window && window . setTimeout ) { const id = window . setTimeout ( handler , timeout ) ; return new DOMTimeout ( id ) ; } const id = setTimeout ( handler , timeout ) ; return new NodeTimeout ( id ) ; } } export interface Timeout { /**
     * Clear this timeout so that it does not run.
     */ clear ( ) : void ; } class DOMTimeout implements Timeout { constructor ( private readonly id ) { } public clear ( ) { window . clearTimeout ( this . id ) ; } } class NodeTimeout implements Timeout { constructor ( private readonly id ) { } public clear ( ) { clearTimeout ( this . id ) ; } }