import { JSDOM } from "jsdom"; import { give, guestCast, GuestType, SourceType, value } from "silentium"; /** * Helps to get Document from html string */ export const jsdomDocument = ( body: SourceType = "", domGuest?: GuestType, ): SourceType => { return (g: GuestType) => { value( body, guestCast(g, (body) => { const dom = new JSDOM(`${body}`); if (domGuest) { give(dom, domGuest); } give(dom.window.document, g); }), ); }; };