
export function stripHtml(html: string): string 
{
    const tmp = document.createElement("DIV");
    tmp.innerHTML = html;
    return tmp.textContent || tmp.innerText || "";
}

/**
 * Do any items in `subjects` fulfil query? 
 */
export function strKeywordSearch(subject: string, query: string): boolean 
{
    const keywords = query.toLowerCase().trim().split(' ').filter(str=>Boolean(str));
    const subjStrLowerCase = subject.toLowerCase();
    
    let included = true;
    for (const word of keywords) {
        included &&= subjStrLowerCase.includes(word);        
    }
    return included;
}

/**
 * @param milliseconds
 */
export async function getDelay(milliseconds: number): Promise<void> {
    return new Promise<void>(resolve => {
        setTimeout(() => resolve(), milliseconds);
    });
}