UNPKG

vanillajs-browser-helpers

Version:

Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser

14 lines (8 loc) 338 B
import type { GeneralWindow } from './shared/types'; import getCurrentDocument from './getCurrentDocument'; import isWindow from './isWindow'; export default function getCurrentWindow(obj: unknown): null | GeneralWindow { if (isWindow(obj)) { return obj; } const doc = getCurrentDocument(obj); return doc && doc.defaultView; }