export const canUseDOM = (): boolean => !!(typeof window !== 'undefined' && window.document); export const xmlParser = (xmlString: string): Document => { const parser = new window.DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); return xmlDoc; }; export const getElementsByTagName = ( elements: ChildNode, tagname: string ): NodeList => { const arr = Array.prototype.slice.call(elements.childNodes); let element: any = null; arr.forEach(ele => { if (ele.tagName === tagname) { element = ele.childNodes; } }); return element; }; export default canUseDOM;