{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TGetElSiblingsArgs = Parameters<typeof getElSiblings>;\r\n\r\nexport type TGetElSiblingsReturn = ReturnType<typeof getElSiblings>;\r\n\r\n/**\r\n * Gets an array of all siblings of given node\r\n * @param el{HTMLElement} node\r\n * @returns {Array}\r\n * @throws {TypeError} getElSiblings: el must be an HTMLElement\r\n * @example\r\n * // How to get all siblings of `li` DOM-element with specific ID?\r\n * // <ul>\r\n * //   <li id=\"item1\">One</li>\r\n * //   <li id=\"item2\">Two</li>\r\n * //   <li id=\"item3\">Three</li>\r\n * // <ul>\r\n * const secondItem = document.getElementById(\"item2\");\r\n * getElSiblings(secondItem).filter(item => item !== secondItem) // [ li#item1, li#utem3 ]\r\n */\r\nexport const getElSiblings = (el: HTMLElement): Array<ChildNode> => {\r\n  if (!el || typeof (el as any).nodeType !== \"number\") {\r\n    throw new TypeError(\"getElSiblings: el must be an HTMLElement\");\r\n  }\r\n\r\n  const siblings = [];\r\n  let sibling = el?.parentNode?.firstChild;\r\n  while (sibling) {\r\n    if (sibling.nodeType === 1 && sibling !== el) {\r\n      siblings.push(sibling);\r\n    }\r\n    sibling = (sibling as any).nextSibling;\r\n  }\r\n  return siblings;\r\n};\r\n"],"names":["getElSiblings","el","nodeType","TypeError","siblings","sibling","parentNode","firstChild","push","nextSibling"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,cAAiBC,KAC5B,IAAKA,WAAcA,GAAWC,WAAa,SACzC,MAAM,IAAIC,UAAU,4CAGtB,MAAMC,SAAW,GACjB,IAAIC,QAAUJ,IAAIK,YAAYC,WAC9B,MAAOF,QAAS,CACd,GAAIA,QAAQH,WAAa,GAAKG,UAAYJ,GACxCG,SAASI,KAAKH,SAEhBA,QAAWA,QAAgBI,WAC7B,CACA,OAAOL"}