@thednp/shorty 1.0.3 → 2.0.0-alpha10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/.eslintrc.cjs +224 -0
  2. package/.lgtm.yml +9 -0
  3. package/.prettierrc.json +15 -0
  4. package/README.md +195 -198
  5. package/cypress/e2e/att.cy.ts +46 -0
  6. package/cypress/e2e/boolean.cy.ts +44 -0
  7. package/cypress/e2e/class.cy.ts +28 -0
  8. package/cypress/e2e/event.cy.ts +51 -0
  9. package/cypress/e2e/get.cy.ts +168 -0
  10. package/cypress/e2e/is.cy.ts +233 -0
  11. package/cypress/e2e/misc.cy.ts +331 -0
  12. package/cypress/e2e/selectors.cy.ts +85 -0
  13. package/cypress/fixtures/custom-elem.js +18 -0
  14. package/cypress/plugins/esbuild-istanbul.ts +50 -0
  15. package/cypress/plugins/tsCompile.ts +34 -0
  16. package/cypress/support/commands.ts +37 -0
  17. package/cypress/support/e2e.ts +21 -0
  18. package/cypress/support/index.js +22 -0
  19. package/cypress/test.html +63 -0
  20. package/cypress.config.ts +30 -0
  21. package/dist/shorty.cjs +2 -0
  22. package/dist/shorty.cjs.map +1 -0
  23. package/dist/shorty.d.ts +1502 -0
  24. package/dist/shorty.js +2 -2628
  25. package/dist/shorty.js.map +1 -0
  26. package/dist/shorty.mjs +552 -0
  27. package/dist/shorty.mjs.map +1 -0
  28. package/dts.config.ts +22 -0
  29. package/package.json +33 -38
  30. package/src/attr/getAttribute.ts +11 -0
  31. package/src/attr/getAttributeNS.ts +12 -0
  32. package/src/attr/hasAttribute.ts +10 -0
  33. package/src/attr/hasAttributeNS.ts +12 -0
  34. package/src/attr/removeAttribute.ts +9 -0
  35. package/src/attr/removeAttributeNS.ts +11 -0
  36. package/src/attr/setAttribute.ts +11 -0
  37. package/src/attr/setAttributeNS.ts +12 -0
  38. package/src/blocks/{documentBody.js → documentBody.ts} +0 -0
  39. package/src/blocks/{documentElement.js → documentElement.ts} +0 -0
  40. package/src/blocks/{documentHead.js → documentHead.ts} +0 -0
  41. package/src/boolean/isApple.ts +14 -0
  42. package/src/boolean/{isFirefox.js → isFirefox.ts} +2 -3
  43. package/src/boolean/{isMobile.js → isMobile.ts} +1 -2
  44. package/src/boolean/support3DTransform.ts +8 -0
  45. package/src/boolean/supportAnimation.ts +8 -0
  46. package/src/boolean/{supportPassive.js → supportPassive.ts} +3 -3
  47. package/src/boolean/supportTouch.ts +7 -0
  48. package/src/boolean/supportTransform.ts +8 -0
  49. package/src/boolean/supportTransition.ts +8 -0
  50. package/src/class/addClass.ts +11 -0
  51. package/src/class/hasClass.ts +11 -0
  52. package/src/class/removeClass.ts +11 -0
  53. package/src/event/off.ts +14 -0
  54. package/src/event/on.ts +14 -0
  55. package/src/event/one.ts +25 -0
  56. package/src/get/{getBoundingClientRect.js → getBoundingClientRect.ts} +14 -12
  57. package/src/get/{getDocument.js → getDocument.ts} +11 -7
  58. package/src/get/getDocumentBody.ts +13 -0
  59. package/src/get/getDocumentElement.ts +13 -0
  60. package/src/get/getDocumentHead.ts +12 -0
  61. package/src/get/{getElementAnimationDelay.js → getElementAnimationDelay.ts} +10 -9
  62. package/src/get/{getElementAnimationDuration.js → getElementAnimationDuration.ts} +10 -8
  63. package/src/get/getElementStyle.ts +25 -0
  64. package/src/get/{getElementTransitionDelay.js → getElementTransitionDelay.ts} +12 -8
  65. package/src/get/{getElementTransitionDuration.js → getElementTransitionDuration.ts} +12 -8
  66. package/src/get/{getNodeScroll.js → getNodeScroll.ts} +9 -5
  67. package/src/get/{getParentNode.js → getParentNode.ts} +11 -6
  68. package/src/get/{getRectRelativeToOffsetParent.js → getRectRelativeToOffsetParent.ts} +15 -7
  69. package/src/get/getUID.ts +42 -0
  70. package/src/get/{getWindow.js → getWindow.ts} +9 -6
  71. package/src/{index.js → index.ts} +37 -43
  72. package/src/interface/boundingClientRect.d.ts +10 -0
  73. package/src/interface/css4Declaration.d.ts +4 -0
  74. package/src/interface/customElement.d.ts +8 -0
  75. package/src/interface/navigatorUA.d.ts +15 -0
  76. package/src/interface/offsetRect.d.ts +6 -0
  77. package/src/interface/originalEvent.d.ts +4 -0
  78. package/src/is/isArray.ts +9 -0
  79. package/src/is/isCanvas.ts +13 -0
  80. package/src/is/isCustomElement.ts +13 -0
  81. package/src/is/isDocument.ts +13 -0
  82. package/src/is/{isElement.js → isElement.ts} +10 -5
  83. package/src/is/{isElementInScrollRange.js → isElementInScrollRange.ts} +4 -4
  84. package/src/is/{isElementInViewport.js → isElementInViewport.ts} +6 -12
  85. package/src/is/isElementsArray.ts +13 -0
  86. package/src/is/isFunction.ts +10 -0
  87. package/src/is/isHTMLCollection.ts +12 -0
  88. package/src/is/isHTMLElement.ts +13 -0
  89. package/src/is/isHTMLImageElement.ts +12 -0
  90. package/src/is/isJSON.ts +20 -0
  91. package/src/is/isMap.ts +11 -0
  92. package/src/is/isMedia.ts +20 -0
  93. package/src/is/isNode.ts +17 -0
  94. package/src/is/isNodeList.ts +13 -0
  95. package/src/is/isNumber.ts +9 -0
  96. package/src/is/isObject.ts +10 -0
  97. package/src/is/isRTL.ts +11 -0
  98. package/src/is/isSVGElement.ts +13 -0
  99. package/src/is/{isScaledElement.js → isScaledElement.ts} +9 -7
  100. package/src/is/isShadowRoot.ts +12 -0
  101. package/src/is/isString.ts +9 -0
  102. package/src/is/isTableElement.ts +14 -0
  103. package/src/is/isWeakMap.ts +11 -0
  104. package/src/is/isWindow.ts +13 -0
  105. package/src/misc/ArrayFrom.ts +11 -0
  106. package/src/misc/Float32ArrayFrom.ts +10 -0
  107. package/src/misc/Float64ArrayFrom.ts +10 -0
  108. package/src/misc/ObjectAssign.ts +43 -0
  109. package/src/misc/ObjectEntries.ts +11 -0
  110. package/src/misc/ObjectHasOwn.ts +17 -0
  111. package/src/misc/ObjectKeys.ts +10 -0
  112. package/src/misc/ObjectValues.ts +11 -0
  113. package/src/misc/createCustomEvent.ts +28 -0
  114. package/src/misc/createElement.ts +40 -0
  115. package/src/misc/createElementNS.ts +45 -0
  116. package/src/misc/data.ts +82 -0
  117. package/src/misc/dispatchEvent.ts +9 -0
  118. package/src/misc/distinct.ts +18 -0
  119. package/src/misc/{emulateAnimationEnd.js → emulateAnimationEnd.ts} +8 -9
  120. package/src/misc/{emulateTransitionEnd.js → emulateTransitionEnd.ts} +8 -9
  121. package/src/misc/focus.ts +9 -0
  122. package/src/misc/getInstance.ts +9 -0
  123. package/src/misc/{noop.js → noop.ts} +4 -1
  124. package/src/misc/normalizeOptions.ts +55 -0
  125. package/src/misc/normalizeValue.ts +30 -0
  126. package/src/misc/{passiveHandler.js → passiveHandler.ts} +1 -2
  127. package/src/misc/reflow.ts +9 -0
  128. package/src/misc/setElementStyle.ts +23 -0
  129. package/src/misc/timer.ts +84 -0
  130. package/src/misc/toLowerCase.ts +9 -0
  131. package/src/misc/toUpperCase.ts +9 -0
  132. package/src/selectors/closest.ts +20 -0
  133. package/src/selectors/{getCustomElements.js → getCustomElements.ts} +8 -4
  134. package/src/selectors/getElementById.ts +16 -0
  135. package/src/selectors/getElementsByClassName.ts +22 -0
  136. package/src/selectors/getElementsByTagName.ts +20 -0
  137. package/src/selectors/matches.ts +10 -0
  138. package/src/selectors/querySelector.ts +22 -0
  139. package/src/selectors/{querySelectorAll.js → querySelectorAll.ts} +7 -5
  140. package/src/strings/{DOMContentLoadedEvent.js → DOMContentLoadedEvent.ts} +0 -1
  141. package/src/strings/{DOMMouseScrollEvent.js → DOMMouseScrollEvent.ts} +0 -1
  142. package/src/strings/{abortEvent.js → abortEvent.ts} +0 -1
  143. package/src/strings/{addEventListener.js → addEventListener.ts} +0 -1
  144. package/src/strings/{animationDelay.js → animationDelay.ts} +0 -1
  145. package/src/strings/{animationDuration.js → animationDuration.ts} +0 -1
  146. package/src/strings/{animationEndEvent.js → animationEndEvent.ts} +0 -1
  147. package/src/strings/{animationName.js → animationName.ts} +0 -1
  148. package/src/strings/{ariaChecked.js → ariaChecked.ts} +0 -1
  149. package/src/strings/{ariaDescribedBy.js → ariaDescribedBy.ts} +0 -1
  150. package/src/strings/{ariaDescription.js → ariaDescription.ts} +0 -1
  151. package/src/strings/{ariaExpanded.js → ariaExpanded.ts} +0 -1
  152. package/src/strings/{ariaHasPopup.js → ariaHasPopup.ts} +0 -1
  153. package/src/strings/{ariaHidden.js → ariaHidden.ts} +0 -1
  154. package/src/strings/{ariaLabel.js → ariaLabel.ts} +0 -1
  155. package/src/strings/{ariaLabelledBy.js → ariaLabelledBy.ts} +0 -1
  156. package/src/strings/{ariaModal.js → ariaModal.ts} +0 -1
  157. package/src/strings/{ariaPressed.js → ariaPressed.ts} +0 -1
  158. package/src/strings/{ariaSelected.js → ariaSelected.ts} +0 -1
  159. package/src/strings/{ariaValueMax.js → ariaValueMax.ts} +0 -1
  160. package/src/strings/{ariaValueMin.js → ariaValueMin.ts} +0 -1
  161. package/src/strings/{ariaValueNow.js → ariaValueNow.ts} +0 -1
  162. package/src/strings/{ariaValueText.js → ariaValueText.ts} +0 -1
  163. package/src/strings/{beforeunloadEvent.js → beforeunloadEvent.ts} +0 -1
  164. package/src/strings/{bezierEasings.js → bezierEasings.ts} +0 -1
  165. package/src/strings/{blurEvent.js → blurEvent.ts} +0 -1
  166. package/src/strings/{changeEvent.js → changeEvent.ts} +0 -1
  167. package/src/strings/{contextmenuEvent.js → contextmenuEvent.ts} +0 -1
  168. package/src/strings/dragEvent.ts +5 -0
  169. package/src/strings/dragendEvent.ts +5 -0
  170. package/src/strings/dragenterEvent.ts +5 -0
  171. package/src/strings/dragleaveEvent.ts +5 -0
  172. package/src/strings/dragoverEvent.ts +5 -0
  173. package/src/strings/dragstartEvent.ts +5 -0
  174. package/src/strings/{errorEvent.js → errorEvent.ts} +0 -1
  175. package/src/strings/{focusEvent.js → focusEvent.ts} +0 -1
  176. package/src/strings/{focusEvents.js → focusEvents.ts} +0 -1
  177. package/src/strings/{focusinEvent.js → focusinEvent.ts} +0 -1
  178. package/src/strings/{focusoutEvent.js → focusoutEvent.ts} +0 -1
  179. package/src/strings/{gesturechangeEvent.js → gesturechangeEvent.ts} +0 -1
  180. package/src/strings/{gestureendEvent.js → gestureendEvent.ts} +0 -1
  181. package/src/strings/{gesturestartEvent.js → gesturestartEvent.ts} +0 -1
  182. package/src/strings/{keyAlt.js → keyAlt.ts} +1 -1
  183. package/src/strings/{keyArrowDown.js → keyArrowDown.ts} +1 -1
  184. package/src/strings/{keyArrowLeft.js → keyArrowLeft.ts} +1 -1
  185. package/src/strings/{keyArrowRight.js → keyArrowRight.ts} +1 -1
  186. package/src/strings/{keyArrowUp.js → keyArrowUp.ts} +1 -1
  187. package/src/strings/{keyBackspace.js → keyBackspace.ts} +1 -1
  188. package/src/strings/{keyCapsLock.js → keyCapsLock.ts} +1 -1
  189. package/src/strings/{keyControl.js → keyControl.ts} +1 -1
  190. package/src/strings/{keyDelete.js → keyDelete.ts} +1 -1
  191. package/src/strings/{keyEnter.js → keyEnter.ts} +1 -1
  192. package/src/strings/{keyEscape.js → keyEscape.ts} +1 -1
  193. package/src/strings/{keyInsert.js → keyInsert.ts} +1 -1
  194. package/src/strings/{keyMeta.js → keyMeta.ts} +1 -1
  195. package/src/strings/{keyPause.js → keyPause.ts} +1 -1
  196. package/src/strings/{keyScrollLock.js → keyScrollLock.ts} +1 -1
  197. package/src/strings/{keyShift.js → keyShift.ts} +1 -1
  198. package/src/strings/{keySpace.js → keySpace.ts} +1 -1
  199. package/src/strings/{keyTab.js → keyTab.ts} +1 -1
  200. package/src/strings/{keyboardEventKeys.js → keyboardEventKeys.ts} +0 -1
  201. package/src/strings/{keydownEvent.js → keydownEvent.ts} +0 -1
  202. package/src/strings/{keypressEvent.js → keypressEvent.ts} +0 -1
  203. package/src/strings/{keyupEvent.js → keyupEvent.ts} +0 -1
  204. package/src/strings/{loadEvent.js → loadEvent.ts} +0 -1
  205. package/src/strings/{loadstartEvent.js → loadstartEvent.ts} +0 -1
  206. package/src/strings/{mouseClickEvents.js → mouseClickEvents.ts} +0 -1
  207. package/src/strings/mouseHoverEvents.ts +8 -0
  208. package/src/strings/{mouseSwipeEvents.js → mouseSwipeEvents.ts} +4 -2
  209. package/src/strings/{mouseclickEvent.js → mouseclickEvent.ts} +0 -1
  210. package/src/strings/{mousedblclickEvent.js → mousedblclickEvent.ts} +0 -1
  211. package/src/strings/{mousedownEvent.js → mousedownEvent.ts} +0 -1
  212. package/src/strings/{mouseenterEvent.js → mouseenterEvent.ts} +0 -1
  213. package/src/strings/{mousehoverEvent.js → mousehoverEvent.ts} +0 -1
  214. package/src/strings/{mouseinEvent.js → mouseinEvent.ts} +0 -1
  215. package/src/strings/{mouseleaveEvent.js → mouseleaveEvent.ts} +0 -1
  216. package/src/strings/{mousemoveEvent.js → mousemoveEvent.ts} +0 -1
  217. package/src/strings/{mouseoutEvent.js → mouseoutEvent.ts} +0 -1
  218. package/src/strings/{mouseoverEvent.js → mouseoverEvent.ts} +0 -1
  219. package/src/strings/{mouseupEvent.js → mouseupEvent.ts} +0 -1
  220. package/src/strings/{mousewheelEvent.js → mousewheelEvent.ts} +0 -1
  221. package/src/strings/{moveEvent.js → moveEvent.ts} +0 -1
  222. package/src/strings/{nativeEvents.js → nativeEvents.ts} +0 -0
  223. package/src/strings/{offsetHeight.js → offsetHeight.ts} +0 -1
  224. package/src/strings/{offsetWidth.js → offsetWidth.ts} +0 -1
  225. package/src/strings/{orientationchangeEvent.js → orientationchangeEvent.ts} +0 -1
  226. package/src/strings/{pointercancelEvent.js → pointercancelEvent.ts} +0 -1
  227. package/src/strings/{pointerdownEvent.js → pointerdownEvent.ts} +0 -1
  228. package/src/strings/{pointerleaveEvent.js → pointerleaveEvent.ts} +0 -1
  229. package/src/strings/{pointermoveEvent.js → pointermoveEvent.ts} +0 -1
  230. package/src/strings/{pointerupEvent.js → pointerupEvent.ts} +0 -1
  231. package/src/strings/{readystatechangeEvent.js → readystatechangeEvent.ts} +0 -1
  232. package/src/strings/{removeEventListener.js → removeEventListener.ts} +0 -1
  233. package/src/strings/{resetEvent.js → resetEvent.ts} +0 -1
  234. package/src/strings/{resizeEvent.js → resizeEvent.ts} +0 -1
  235. package/src/strings/{scrollEvent.js → scrollEvent.ts} +0 -1
  236. package/src/strings/{scrollHeight.js → scrollHeight.ts} +0 -1
  237. package/src/strings/{scrollWidth.js → scrollWidth.ts} +0 -1
  238. package/src/strings/{selectEvent.js → selectEvent.ts} +0 -1
  239. package/src/strings/{selectendEvent.js → selectendEvent.ts} +0 -1
  240. package/src/strings/{selectstartEvent.js → selectstartEvent.ts} +0 -1
  241. package/src/strings/{submitEvent.js → submitEvent.ts} +0 -1
  242. package/src/strings/tabindex.ts +5 -0
  243. package/src/strings/touchEvents.ts +10 -0
  244. package/src/strings/{touchcancelEvent.js → touchcancelEvent.ts} +0 -1
  245. package/src/strings/{touchendEvent.js → touchendEvent.ts} +0 -1
  246. package/src/strings/{touchmoveEvent.js → touchmoveEvent.ts} +0 -1
  247. package/src/strings/{touchstartEvent.js → touchstartEvent.ts} +0 -1
  248. package/src/strings/{transitionDelay.js → transitionDelay.ts} +0 -1
  249. package/src/strings/{transitionDuration.js → transitionDuration.ts} +0 -1
  250. package/src/strings/{transitionEndEvent.js → transitionEndEvent.ts} +0 -1
  251. package/src/strings/{transitionProperty.js → transitionProperty.ts} +0 -2
  252. package/src/strings/{unloadEvent.js → unloadEvent.ts} +0 -1
  253. package/src/strings/{userAgent.js → userAgent.ts} +0 -0
  254. package/src/strings/userAgentData.ts +9 -0
  255. package/tsconfig.json +30 -0
  256. package/vite.config.ts +30 -0
  257. package/dist/shorty.esm.js +0 -2599
  258. package/dist/shorty.esm.min.js +0 -2
  259. package/dist/shorty.min.js +0 -2
  260. package/src/attr/getAttribute.js +0 -9
  261. package/src/attr/getAttributeNS.js +0 -10
  262. package/src/attr/hasAttribute.js +0 -9
  263. package/src/attr/hasAttributeNS.js +0 -10
  264. package/src/attr/removeAttribute.js +0 -9
  265. package/src/attr/removeAttributeNS.js +0 -10
  266. package/src/attr/setAttribute.js +0 -10
  267. package/src/attr/setAttributeNS.js +0 -11
  268. package/src/boolean/isApple.js +0 -13
  269. package/src/boolean/support3DTransform.js +0 -9
  270. package/src/boolean/supportAnimation.js +0 -9
  271. package/src/boolean/supportTouch.js +0 -7
  272. package/src/boolean/supportTransform.js +0 -9
  273. package/src/boolean/supportTransition.js +0 -9
  274. package/src/class/addClass.js +0 -10
  275. package/src/class/hasClass.js +0 -10
  276. package/src/class/removeClass.js +0 -10
  277. package/src/event/off.js +0 -9
  278. package/src/event/on.js +0 -9
  279. package/src/event/one.js +0 -23
  280. package/src/get/getDocumentBody.js +0 -10
  281. package/src/get/getDocumentElement.js +0 -11
  282. package/src/get/getDocumentHead.js +0 -10
  283. package/src/get/getElementAnimationDelayLegacy.js +0 -21
  284. package/src/get/getElementAnimationDurationLegacy.js +0 -21
  285. package/src/get/getElementStyle.js +0 -20
  286. package/src/get/getElementTransitionDelayLegacy.js +0 -21
  287. package/src/get/getElementTransitionDurationLegacy.js +0 -21
  288. package/src/get/getUID.js +0 -34
  289. package/src/is/isArray.js +0 -8
  290. package/src/is/isCustomElement.js +0 -8
  291. package/src/is/isDocument.js +0 -10
  292. package/src/is/isElementsArray.js +0 -12
  293. package/src/is/isFunction.js +0 -8
  294. package/src/is/isHTMLCollection.js +0 -8
  295. package/src/is/isHTMLElement.js +0 -9
  296. package/src/is/isHTMLImageElement.js +0 -8
  297. package/src/is/isMedia.js +0 -14
  298. package/src/is/isNode.js +0 -9
  299. package/src/is/isNodeList.js +0 -9
  300. package/src/is/isNumber.js +0 -8
  301. package/src/is/isObject.js +0 -8
  302. package/src/is/isRTL.js +0 -9
  303. package/src/is/isSVGElement.js +0 -11
  304. package/src/is/isShadowRoot.js +0 -9
  305. package/src/is/isString.js +0 -8
  306. package/src/is/isTableElement.js +0 -11
  307. package/src/is/isWindow.js +0 -9
  308. package/src/misc/ArrayFrom.js +0 -8
  309. package/src/misc/Float32ArrayFrom.js +0 -7
  310. package/src/misc/Float64ArrayFrom.js +0 -7
  311. package/src/misc/ObjectAssign.js +0 -7
  312. package/src/misc/ObjectEntries.js +0 -7
  313. package/src/misc/ObjectKeys.js +0 -7
  314. package/src/misc/ObjectValues.js +0 -7
  315. package/src/misc/OriginalEvent.js +0 -20
  316. package/src/misc/createElement.js +0 -27
  317. package/src/misc/createElementNS.js +0 -30
  318. package/src/misc/data.js +0 -78
  319. package/src/misc/dispatchEvent.js +0 -8
  320. package/src/misc/distinct.js +0 -10
  321. package/src/misc/emulateAnimationEndLegacy.js +0 -41
  322. package/src/misc/emulateTransitionEndLegacy.js +0 -41
  323. package/src/misc/focus.js +0 -7
  324. package/src/misc/normalizeOptions.js +0 -49
  325. package/src/misc/normalizeValue.js +0 -34
  326. package/src/misc/passiveHandlerLegacy.js +0 -10
  327. package/src/misc/reflow.js +0 -8
  328. package/src/misc/setElementStyle.js +0 -19
  329. package/src/misc/timer.js +0 -75
  330. package/src/misc/toLowerCase.js +0 -8
  331. package/src/misc/toUpperCase.js +0 -8
  332. package/src/misc/version.js +0 -8
  333. package/src/selectors/closest.js +0 -16
  334. package/src/selectors/getElementById.js +0 -14
  335. package/src/selectors/getElementsByClassName.js +0 -15
  336. package/src/selectors/getElementsByTagName.js +0 -15
  337. package/src/selectors/matches.js +0 -10
  338. package/src/selectors/matchesLegacy.js +0 -23
  339. package/src/selectors/querySelector.js +0 -19
  340. package/src/strings/animationDelayLegacy.js +0 -9
  341. package/src/strings/animationDurationLegacy.js +0 -9
  342. package/src/strings/animationEndEventLegacy.js +0 -9
  343. package/src/strings/animationNameLegacy.js +0 -9
  344. package/src/strings/mouseHoverEvents.js +0 -7
  345. package/src/strings/touchEvents.js +0 -8
  346. package/src/strings/transitionDelayLegacy.js +0 -9
  347. package/src/strings/transitionDurationLegacy.js +0 -9
  348. package/src/strings/transitionEndEventLegacy.js +0 -9
  349. package/src/strings/transitionPropertyLegacy.js +0 -12
  350. package/src/strings/userAgentData.js +0 -7
  351. package/types/index.d.ts +0 -257
  352. package/types/module/shorty.ts +0 -248
  353. package/types/shorty.d.ts +0 -2316
package/README.md CHANGED
@@ -1,31 +1,37 @@
1
1
  # shorty
2
+
2
3
  [![Coverage Status](https://coveralls.io/repos/github/thednp/shorty/badge.svg)](https://coveralls.io/github/thednp/shorty)
3
4
  [![ci](https://github.com/thednp/shorty/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/shorty/actions/workflows/ci.yml)
4
5
  [![NPM Version](https://img.shields.io/npm/v/@thednp/shorty.svg)](https://www.npmjs.com/package/@thednp/shorty)
5
6
  [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/shorty.svg)](http://npm-stat.com/charts.html?package=@thednp/shorty)
6
7
  [![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hw/@thednp/shorty)](https://www.jsdelivr.com/package/npm/@thednp/shorty)
7
- ![cypress version](https://img.shields.io/badge/cypress-9.7.0-brightgreen)
8
- ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
8
+ [![typescript version](https://img.shields.io/badge/typescript-4.9.4-brightgreen)](https://www.typescriptlang.org/)
9
+ [![eslint version](https://img.shields.io/badge/eslint-8.29.0-brightgreen)](https://github.com/eslint)
10
+ [![prettier version](https://img.shields.io/badge/prettier-2.8.3-brightgreen)](https://prettier.io/)
11
+ [![cypress version](https://img.shields.io/badge/cypress-12.4.1-brightgreen)](https://cypress.io/)
12
+ [![vite version](https://img.shields.io/badge/vite-4.0.4-brightgreen)](https://github.com/vitejs)
9
13
 
10
- A small ES6+ library with various JavaScript tools, all ESLint valid and with TypeScript definitions, everything useful for creating light libraries or web components. If there is anything that is consistently repeating itself, **shorty** can help you save up to 50% of the code required, with little to no performance cost.
11
14
 
15
+ A small TypeScript library with various tools, all ESLint valid and featuring everything useful for creating light libraries or web components. If there is anything that is consistently repeating itself, **shorty** can help you save up to 50% of the code required, with little to no performance cost.
12
16
 
13
17
  **shorty** is featured in [ColorPicker](https://github.com/thednp/color-picker), [KUTE.js](https://github.com/thednp/kute.js), [BSN](https://github.com/thednp/bootstrap.native), [Navbar.js](https://github.com/thednp/navbar.js) and other libraries.
14
18
 
15
- * The purpose of the library is to speed up the development workflow, minimize the size of larger libraries by providing a shorter syntax for most used JavaScript API methods, most used strings or other helpful utilities.
16
- * Another excellent use for the library is for its selectors in a testing environment where you need to check the `instanceof` for various objects.
17
- * While the library comes with a working build in the `dist` folder, that is mainly for build consistency testing. You can make use of "tree shaking" to import one or anything your code needs.
18
- * On that note, all shorties are organized in folders inside the `src` root folder, the structure is key to understanding the purpose of each type of shortie, whether we have `boolean` for various basic browser detection or browser feature support, `attr` for all things *Element* attributes or `strings` for most common and most used *Element.prototype* methods.
19
+ - The purpose of the library is to speed up the development workflow, minimize the size of larger libraries by providing a shorter syntax for most used JavaScript API methods, most used strings or other helpful utilities.
20
+ - Another excellent use for the library is for its selectors in a testing environment where you need to check the `instanceof` for various objects.
21
+ - While the library comes with a working build in the `dist` folder, that is mainly for build consistency testing. You can make use of "tree shaking" to import one or anything your code needs.
22
+ - On that note, all shorties are organized in folders inside the `src` root folder, the structure is key to understanding the purpose of each type of shortie, whether we have `boolean` for various basic browser detection or browser feature support, `attr` for all things _Element_ attributes or `strings` for most common and most used _Element.prototype_ methods.
19
23
 
20
24
  # npm
25
+
21
26
  ```
22
27
  npm install @thednp/shorty
23
28
  ```
24
29
 
25
- # ES6+ Base usage
30
+ # TypeScript / ES6+ Base usage
31
+
26
32
  ```js
27
33
  // import the tool you need
28
- import { supportTransform } from '@thednp/shorty';
34
+ import { supportTransform } from "@thednp/shorty";
29
35
 
30
36
  // use the tool in your ES6/ES7 sources
31
37
  if (supportTransform) {
@@ -34,160 +40,156 @@ if (supportTransform) {
34
40
  ```
35
41
 
36
42
  # attr
37
- * ***getAttribute*** - returns the value of a specified *Element* attribute;
38
- * ***getAttributeNS*** - returns the value of a specified namespaced *Element* attribute (eg: namespaced SVG attributes);
39
- * ***hasAttribute*** - check if element has a specified attribute;
40
- * ***hasAttributeNS*** - check if element has a specified namespaced attribute;
41
- * ***removeAttribute*** - removes a specified attribute from an element;
42
- * ***removeAttributeNS*** - removes a specified namespaced attribute from an element;
43
- * ***setAttribute*** - set a new attribute value for a given element;
44
- * ***setAttributeNS*** - set a new namespaced attribute value for a given element;
45
-
46
- ```js
43
+
44
+ - **_getAttribute_** - returns the value of a specified _Element_ attribute;
45
+ - **_getAttributeNS_** - returns the value of a specified namespaced _Element_ attribute (eg: namespaced SVG attributes);
46
+ - **_hasAttribute_** - check if element has a specified attribute;
47
+ - **_hasAttributeNS_** - check if element has a specified namespaced attribute;
48
+ - **_removeAttribute_** - removes a specified attribute from an element;
49
+ - **_removeAttributeNS_** - removes a specified namespaced attribute from an element;
50
+ - **_setAttribute_** - set a new attribute value for a given element;
51
+ - **_setAttributeNS_** - set a new namespaced attribute value for a given element;
52
+
53
+ ```js
47
54
  // EXAMPLES
48
- import { getAttribute, hasAttribute, setAttribute } from '@thednp/shorty';
55
+ import { getAttribute, hasAttribute, setAttribute } from "@thednp/shorty";
49
56
 
50
57
  // check target has certain attribute
51
- if (!hasAttribute(myTarget, 'attribute-name')) {
52
- setAttribute(myTarget, 'attribute-name', 'new-value');
58
+ if (!hasAttribute(myTarget, "attribute-name")) {
59
+ setAttribute(myTarget, "attribute-name", "new-value");
53
60
  }
54
61
 
55
62
  // get attribute value
56
- const currentAttrValue = getAttribute(myTarget, 'attribute-name');
63
+ const currentAttrValue = getAttribute(myTarget, "attribute-name");
57
64
  ```
58
65
 
59
-
60
66
  # blocks
61
- * ***documentBody*** - a shortie for `document.body`;
62
- * ***documentElement*** - a shortie for `document.documentElement`;
63
- * ***documentHead*** - a shortie for `document.head`;
67
+
68
+ - **_documentBody_** - a shortie for `document.body`;
69
+ - **_documentElement_** - a shortie for `document.documentElement`;
70
+ - **_documentHead_** - a shortie for `document.head`;
64
71
 
65
72
  # boolean
66
- * ***isApple*** - checks and preserves a `boolean` value for the client browser is either Apple **Safari** browser or not;
67
- * ***isFirefox*** - checks and preserves a `boolean` value for the client browser is either **Firefox** or not;
68
- * ***isMobile*** - checks and preserves a `boolean` value for the client browser is either a Mobile device or not;
69
- * ***support3DTransform*** - checks and preserves a `boolean` value for the client browser capability for webKit `perspective`;
70
- * ***supportTouch*** - checks and preserves a `boolean` value for the client browser capability for `touch` events;
71
- * ***supportPassive*** - checks and preserves a `boolean` value for the client browser capability for `passive` event option;
72
- * ***supportTransform*** - checks and preserves a `boolean` value for the client browser capability for webKit `transform`;
73
- * ***supportAnimation*** - checks and preserves a `boolean` value for the client browser capability for webKit keyframe `animation`;
74
- * ***supportTransition*** - checks and preserves a `boolean` value for the client browser capability for webKit `transition`;
75
-
76
- ```js
73
+
74
+ - **_isApple_** - checks and preserves a `boolean` value for the client browser is either Apple **Safari** browser or not;
75
+ - **_isFirefox_** - checks and preserves a `boolean` value for the client browser is either **Firefox** or not;
76
+ - **_isMobile_** - checks and preserves a `boolean` value for the client browser is either a Mobile device or not;
77
+ - **_support3DTransform_** - checks and preserves a `boolean` value for the client browser capability for webKit `perspective`;
78
+ - **_supportTouch_** - checks and preserves a `boolean` value for the client browser capability for `touch` events;
79
+ - **_supportPassive_** - checks and preserves a `boolean` value for the client browser capability for `passive` event option;
80
+ - **_supportTransform_** - checks and preserves a `boolean` value for the client browser capability for webKit `transform`;
81
+ - **_supportAnimation_** - checks and preserves a `boolean` value for the client browser capability for webKit keyframe `animation`;
82
+ - **_supportTransition_** - checks and preserves a `boolean` value for the client browser capability for webKit `transition`;
83
+
84
+ ```js
77
85
  // EXAMPLES
78
- import { support3DTransform } from '@thednp/shorty';
86
+ import { support3DTransform } from "@thednp/shorty";
79
87
 
80
88
  // filter myAction to supported browsers
81
89
  if (support3DTransform) {
82
90
  // do something with modern browsers
83
91
  }
84
92
  ```
85
-
93
+
86
94
  # class
87
- * ***addClass*** - add a class to a target *Element*;
88
- * ***removeClass*** - remove a class from a target *Element*;
89
- * ***hasClass*** - checks the existence of a class for a target *Element*;
90
95
 
91
- ```js
96
+ - **_addClass_** - add a class to a target _Element_;
97
+ - **_removeClass_** - remove a class from a target _Element_;
98
+ - **_hasClass_** - checks the existence of a class for a target _Element_;
99
+
100
+ ```js
92
101
  // EXAMPLES
93
- import { addClass, removeClass, hasClass } from '@thednp/shorty'
102
+ import { addClass, removeClass, hasClass } from "@thednp/shorty";
94
103
 
95
104
  // add a class
96
- addClass(targetElement, 'className');
105
+ addClass(targetElement, "className");
97
106
 
98
107
  // remove a class
99
- removeClass(targetElement, 'className');
108
+ removeClass(targetElement, "className");
100
109
 
101
110
  // check for a class
102
- if (hasClass(targetElement, 'className')) {
111
+ if (hasClass(targetElement, "className")) {
103
112
  // do something about that
104
113
  }
105
114
  ```
106
115
 
107
116
  # event
108
- * ***on*** - attach an event listener to a specific target *Element*;
109
- * ***off*** - detach an event listener from a specific target *Element*;
110
- * ***one*** - attach an event listener to a specific target *Element*, and detach when complete;
111
117
 
112
- ```js
118
+ - **_on_** - attach an event listener to a specific target _Element_;
119
+ - **_off_** - detach an event listener from a specific target _Element_;
120
+ - **_one_** - attach an event listener to a specific target _Element_, and detach when complete;
121
+
122
+ ```js
113
123
  // EXAMPLES
114
- import { on, off, one, passiveHandler } from '@thednp/shorty';
124
+ import { on, off, one, passiveHandler } from "@thednp/shorty";
115
125
 
116
126
  // attach a passive mousedown eventHandler
117
- on(targetElement, 'click', eventHandler, passiveHandler);
127
+ on(targetElement, "click", eventHandler, passiveHandler);
118
128
 
119
129
  // detach a passive mouseup eventHandler
120
- off(targetElement, 'mouseup', eventHandler, passiveHandler);
130
+ off(targetElement, "mouseup", eventHandler, passiveHandler);
121
131
 
122
132
  // attach a single instance passive touchstart eventHandler
123
- one(targetElement, 'touchstart', eventHandler, passiveHandler);
133
+ one(targetElement, "touchstart", eventHandler, passiveHandler);
124
134
  ```
125
135
 
126
- For a more advanced method to handle event listeners, I recommend using the [event-listener.js](github.com/thednp/event-listener.js).
127
-
136
+ For a more advanced method to handle event listeners, I recommend using the [event-listener](github.com/thednp/event-listener).
128
137
 
129
138
  # get
130
- * ***getBoundingClientRect*** - returns the bounding client rectangle of a given *Element*;
131
- * ***getDocument*** - returns the containing `#Document` for a given *Element* or just any *Document*, useful when working with *iframe*s;
132
- * ***getDocumentBody*** - returns the containing `<body>` for a given *Element* or just any;
133
- * ***getDocumentElement*** - returns the containing `<html>` for a given *Element* or just any;
134
- * ***getDocumentHead*** - returns the containing `<head>` for a given *Element* or just any;
135
- * ***getElementAnimationDelay*** - returns the `animationDelay` property of an `animation` property;
136
- * ***getElementAnimationDelayLegacy*** - for legacy browsers;
137
- * ***getElementAnimationDuration*** - returns the `animationDuration` property of a `animation` property;
138
- * ***getElementAnimationDurationLegacy*** - for legacy browsers;
139
- * ***getElementTransitionDelay*** - returns the `transitionDelay` property of a `transition` property;
140
- * ***getElementTransitionDelayLegacy*** - for legacy browsers;
141
- * ***getElementTransitionDuration*** - returns the `transitionDuration` property of a `transition` property;
142
- * ***getElementTransitionDurationLegacy*** - for legacy browsers;
143
- * ***getElementStyle*** - returns the *Element* computed style for a given property;
144
- * ***getNodeScroll*** - returns the *Element* / *Window* current `{ x, y }` scroll position;
145
- * ***getParentNode*** - returns parent of a given *Element*;
146
- * ***getRectRelativeToOffsetParent*** - returns the bounding client rectangle of a given *Element* relative to a given `offsetParent`;
147
- * ***getUID*** - a nice utility that creates a unique ID for a given *Element* and returns it;
148
- * ***getWindow*** - returns the containing `Window` for a given *Element* or just any *Window*;
149
-
150
- ```js
139
+
140
+ - **_getBoundingClientRect_** - returns the bounding client rectangle of a given _Element_;
141
+ - **_getDocument_** - returns the containing `#Document` for a given _Element_ or just any _Document_, useful when working with *iframe*s;
142
+ - **_getDocumentBody_** - returns the containing `<body>` for a given _Element_ or just any;
143
+ - **_getDocumentElement_** - returns the containing `<html>` for a given _Element_ or just any;
144
+ - **_getDocumentHead_** - returns the containing `<head>` for a given _Element_ or just any;
145
+ - **_getElementAnimationDelay_** - returns the `animationDelay` property of an `animation` property;
146
+ - **_getElementAnimationDuration_** - returns the `animationDuration` property of a `animation` property;
147
+ - **_getElementTransitionDelay_** - returns the `transitionDelay` property of a `transition` property;
148
+ - **_getElementTransitionDuration_** - returns the `transitionDuration` property of a `transition` property;
149
+ - **_getElementStyle_** - returns the _Element_ computed style for a given property;
150
+ - **_getNodeScroll_** - returns the _Element_ / _Window_ current `{ x, y }` scroll position;
151
+ - **_getParentNode_** - returns parent of a given _Element_;
152
+ - **_getRectRelativeToOffsetParent_** - returns the bounding client rectangle of a given _Element_ relative to a given `offsetParent`;
153
+ - **_getUID_** - a nice utility that creates a unique ID for a given _Element_ and returns it;
154
+ - **_getWindow_** - returns the containing `Window` for a given _Element_ or just any _Window_;
155
+
156
+ ```js
151
157
  // EXAMPLES
152
- import {
153
- getElementAnimationDuration,
154
- getElementAnimationDurationLegacy,
155
- } from '@thednp/shorty'
158
+ import { getElementAnimationDuration } from "@thednp/shorty";
156
159
 
157
160
  // store the transition duration for target element on a modern browser
158
161
  const duration = getElementAnimationDuration(target);
159
-
160
- // or do the same with legacy browser fallback
161
- const duration = getElementAnimationDurationLegacy(target);
162
162
  ```
163
163
 
164
164
  # is
165
- * ***isArray*** - check if a given value is an `Array`;
166
- * ***isCustomElement*** - check if a given value is a `CustomElement` instance;
167
- * ***isDocument*** - check if a given value is a `Document` instance;
168
- * ***isElement*** - check if a given value is an `Element` instance;
169
- * ***isElementInScrollRange*** - check if a given `Element` is partially visible in the viewport;
170
- * ***isElementInViewport*** - check if a given `Element` is fully visible in the viewport;
171
- * ***isElementsArray*** - check if a given value is an `Array` with `Element` instances;
172
- * ***isFunction*** - check if a given value is a `Function` instance;
173
- * ***isHTMLCollection*** - check if a given value is an `HTMLCollection` instance;
174
- * ***isHTMLElement*** - check if a given value is an `HTMLElement` instance;
175
- * ***isHTMLImageElement*** - check if a given value is an `HTMLImageElement` instance;
176
- * ***isMedia*** - check if a given value is an `SVGElement`, `HTMLImageElement` or `HTMLVideoElement` instance;
177
- * ***isNode*** - check if a given value is a `Node` instance;
178
- * ***isNodeList*** - check if a given value is a `NodeList` instance;
179
- * ***isNumber*** - check if a given value is string;
180
- * ***isRTL*** - check if a given node is contained in a `<html dir="rtl">`;
181
- * ***isScaledElement*** - check if a given *Element* is affected by scale;
182
- * ***isShadowRoot*** - check if a given *Node* is a `ShadowRoot` instance;
183
- * ***isString*** - check if a given value is string;
184
- * ***isSVGElement*** - check if a given value is `SVGElement` instance;
185
- * ***isTableElement*** - check if a given value is `<table>`, `<td>` or `<th>` *Element*;
186
- * ***isWindow*** - check if a given value is a `Window` instance;
187
-
188
- ```js
165
+
166
+ - **_isArray_** - check if a given value is an `Array`;
167
+ - **_isCanvas_** - check if a given value is a `HTMLCanvasElement` instance;
168
+ - **_isCustomElement_** - check if a given value is a `CustomElement` instance;
169
+ - **_isDocument_** - check if a given value is a `Document` instance;
170
+ - **_isElement_** - check if a given value is an `Element` instance;
171
+ - **_isElementInScrollRange_** - check if a given `Element` is partially visible in the viewport;
172
+ - **_isElementInViewport_** - check if a given `Element` is fully visible in the viewport;
173
+ - **_isElementsArray_** - check if a given value is an `Array` with `Element` instances;
174
+ - **_isFunction_** - check if a given value is a `Function` instance;
175
+ - **_isHTMLCollection_** - check if a given value is an `HTMLCollection` instance;
176
+ - **_isHTMLElement_** - check if a given value is an `HTMLElement` instance;
177
+ - **_isHTMLImageElement_** - check if a given value is an `HTMLImageElement` instance;
178
+ - **_isMedia_** - check if a given value is an `SVGElement`, `HTMLImageElement`, `HTMLCanvasElement` or `HTMLVideoElement` instance;
179
+ - **_isNode_** - check if a given value is a `Node` instance;
180
+ - **_isNodeList_** - check if a given value is a `NodeList` instance;
181
+ - **_isNumber_** - check if a given value is string;
182
+ - **_isRTL_** - check if a given node is contained in a `<html dir="rtl">`;
183
+ - **_isScaledElement_** - check if a given _Element_ is affected by scale;
184
+ - **_isShadowRoot_** - check if a given _Node_ is a `ShadowRoot` instance;
185
+ - **_isString_** - check if a given value is string;
186
+ - **_isSVGElement_** - check if a given value is `SVGElement` instance;
187
+ - **_isTableElement_** - check if a given value is `<table>`, `<td>` or `<th>` _Element_;
188
+ - **_isWindow_** - check if a given value is a `Window` instance;
189
+
190
+ ```js
189
191
  // EXAMPLES
190
- import { isArray, isHTMLElement, isElementsArray } from '@thednp/shorty';
192
+ import { isArray, isHTMLElement, isElementsArray } from "@thednp/shorty";
191
193
 
192
194
  // check if a value is an `Array` of `Element` instances
193
195
  if (isArray(myValue) && myValue.every(isHTMLElement)) {
@@ -201,40 +203,39 @@ if (isElementsArray(myValue)) {
201
203
  ```
202
204
 
203
205
  # misc
204
- * ***ArrayFrom*** - a shortie for `Array.from()` method;
205
- * ***Data*** - a small utility to store web components data that makes use of the native `Map`;
206
- * ***dispatchEvent*** - a shortie for `Element.dispatchEvent()` method;
207
- * ***distinct*** - a shortie you can use to filter duplicate values in an `Array`;
208
- * ***emulateAnimationEnd*** - utility to execute a callback function when `animationend` event is triggered, or execute the callback right after for legacy browsers;
209
- * ***emulateAnimationEndLegacy*** - for legacy browsers;
210
- * ***emulateTransitionEnd*** - utility to execute a callback function when `transitionend` event is triggered, or execute the callback right after for legacy browsers;
211
- * ***emulateTransitionEndLegacy*** - for legacy browsers;
212
- * ***Float32ArrayFrom*** - a shortie for `Float32Array.from()` method;
213
- * ***Float64ArrayFrom*** - a shortie for `Float64Array.from()` method;
214
- * ***focus*** - a shortie for `Element.focus()` method;
215
- * ***noop*** - is your regular `() => {}` NOOP;
216
- * ***normalizeOptions*** - a cool utility to normalize and crosscheck JavaScript options and their DATA API counterparts for various web components; supports namespaced options like `data-NAMESPACE-option="value"`; priority: JavaScript options > DATA API options > default options
217
- * ***ObjectAssign*** - a shortie for `Object.assign()` method;
218
- * ***ObjectEntries*** - a shortie for `Object.entries()` method;
219
- * ***ObjectKeys*** - a shortie for `Object.keys()` method;
220
- * ***ObjectValues*** - a shortie for `Object.values()` method;
221
- * ***OriginalEvent*** - a small utility that returns a synthetic `CustomEvent` with the added `relatedTarget` and other properties;
222
- * ***passiveHandler*** - a constant that preserves a standard listener `options` with `passive: true` event option used;
223
- * ***passiveHandlerLegacy*** - for legacy browsers;
224
- * ***reflow*** - a small utility that force repaint of a given *Element* by "checking" its `offsetHeight` value, also because using just `element.offsetHeight;` won't validate on ESLint;
225
- * ***setElementStyle*** - a small utility that allows you to set multiple CSS properties at once for a given *Element* target;
226
- * ***Timer*** - a small but powerful utility that makes `setTimeout` have a meaning;
227
- * ***toLowerCase*** - a shortie for `String.toLowerCase()` method;
228
- * ***toUpperCase*** - a shortie for `String.toUpperCase()` method;
229
-
230
- The ***Data*** and ***Timer*** utilities have their own specifics, you might want to check the [wiki](https://github.com/thednp/shorty/wiki).
231
-
232
- ```js
206
+
207
+ - **_ArrayFrom_** - a shortie for `Array.from()` method;
208
+ - **_Data_** - a small utility to store web components data that makes use of the native `Map`;
209
+ - **_dispatchEvent_** - a shortie for `Element.dispatchEvent()` method;
210
+ - **_distinct_** - a shortie you can use to filter duplicate values in an `Array`;
211
+ - **_emulateAnimationEnd_** - utility to execute a callback function when `animationend` event is triggered, or execute the callback right after for legacy browsers;
212
+ - **_emulateAnimationEndLegacy_** - for legacy browsers;
213
+ - **_emulateTransitionEnd_** - utility to execute a callback function when `transitionend` event is triggered, or execute the callback right after for legacy browsers;
214
+ - **_emulateTransitionEndLegacy_** - for legacy browsers;
215
+ - **_Float32ArrayFrom_** - a shortie for `Float32Array.from()` method;
216
+ - **_Float64ArrayFrom_** - a shortie for `Float64Array.from()` method;
217
+ - **_focus_** - a shortie for `Element.focus()` method;
218
+ - **_noop_** - is your regular `() => {}` NOOP;
219
+ - **_normalizeOptions_** - a cool utility to normalize and crosscheck JavaScript options and their DATA API counterparts for various web components; supports namespaced options like `data-NAMESPACE-option="value"`; priority: JavaScript options > DATA API options > default options
220
+ - **_ObjectAssign_** - a shortie for `Object.assign()` method;
221
+ - **_ObjectEntries_** - a shortie for `Object.entries()` method;
222
+ - **_ObjectHasOwn_** - a shortie for `Object.hasOwn()` method;
223
+ - **_ObjectKeys_** - a shortie for `Object.keys()` method;
224
+ - **_ObjectValues_** - a shortie for `Object.values()` method;
225
+ - **_OriginalEvent_** - a small utility that returns a synthetic `CustomEvent` with the added `relatedTarget` and other properties;
226
+ - **_passiveHandler_** - a constant that preserves a standard listener `options` with `passive: true` event option used;
227
+ - **_passiveHandlerLegacy_** - for legacy browsers;
228
+ - **_reflow_** - a small utility that force repaint of a given _Element_ by "checking" its `offsetHeight` value, also because using just `element.offsetHeight;` won't validate on ESLint;
229
+ - **_setElementStyle_** - a small utility that allows you to set multiple CSS properties at once for a given _Element_ target;
230
+ - **_Timer_** - a small but powerful utility that makes `setTimeout` have a meaning;
231
+ - **_toLowerCase_** - a shortie for `String.toLowerCase()` method;
232
+ - **_toUpperCase_** - a shortie for `String.toUpperCase()` method;
233
+
234
+ The **_Data_** and **_Timer_** utilities have their own specifics, you might want to check the [wiki](https://github.com/thednp/shorty/wiki).
235
+
236
+ ```js
233
237
  // EXAMPLES
234
- import {
235
- emulateTransitionEnd,
236
- distinct,
237
- } from '@thednp/shorty';
238
+ import { emulateTransitionEnd, distinct } from "@thednp/shorty";
238
239
 
239
240
  // execute a callback when transitionend is triggered for the target
240
241
  emulateTransitionEnd(targetElement, callback);
@@ -249,60 +250,54 @@ const array3 = [...array1, ...array2].filter(distinct);
249
250
  ```
250
251
 
251
252
  # selectors
252
- * ***closest*** - a shortie for `Element.closest()` method;
253
- * ***getCustomElements*** - returns an `Array` with all registered `CustomElement`;
254
- * ***getElementById*** - a shortie for `document.getElementById()` method;
255
- * ***getElementsByClassName*** - a shortie for `Element.getElementsByClassName()` method;
256
- * ***getElementsByTagName*** - a shortie for `Element.getElementsByTagName()` method;
257
- * ***matches*** - a shortie for `Element.matches()` method;
258
- * ***matchesLegacy*** - for legacy browsers;
259
- * ***querySelector*** - a simple utility to check if a given value is an *Element* or a selector string, and if a selector string find the FIRST *Element* and return it;
260
- * ***querySelectorAll*** - a simple utility to check if a certain item is an *Element* or a selector string, and if a selector string find the FIRST *Element* and return it;
261
-
262
- ```js
253
+
254
+ - **_closest_** - a shortie for `Element.closest()` method;
255
+ - **_getCustomElements_** - returns an `Array` with all registered `CustomElement`;
256
+ - **_getElementById_** - a shortie for `document.getElementById()` method;
257
+ - **_getElementsByClassName_** - a shortie for `Element.getElementsByClassName()` method;
258
+ - **_getElementsByTagName_** - a shortie for `Element.getElementsByTagName()` method;
259
+ - **_matches_** - a shortie for `Element.matches()` method;
260
+ - **_matchesLegacy_** - for legacy browsers;
261
+ - **_querySelector_** - a simple utility to check if a given value is an _Element_ or a selector string, and if a selector string find the FIRST _Element_ and return it;
262
+ - **_querySelectorAll_** - a simple utility to check if a certain item is an _Element_ or a selector string, and if a selector string find the FIRST _Element_ and return it;
263
+
264
+ ```js
263
265
  // EXAMPLES
264
- import { querySelector, querySelectorAll, documentAll, matches } from '@thednp/shorty';
266
+ import { querySelector, querySelectorAll, documentAll, matches } from "@thednp/shorty";
265
267
 
266
268
  // get first element that matches a certain selector
267
- const element = querySelector('.my-class-name');
269
+ const element = querySelector(".my-class-name");
268
270
 
269
271
  // get all elements that matches same selector
270
- const elements = querySelectorAll('.my-class-name');
272
+ const elements = querySelectorAll(".my-class-name");
271
273
 
272
274
  // now do the same as the above, but differently
273
- const elements = [...documentAll].filter((x) => matches(x, '.my-class-name'));
275
+ const elements = [...documentAll].filter((x) => matches(x, ".my-class-name"));
274
276
  ```
275
277
 
276
278
  # strings
277
- * ***bezierEasings*** - an *Object* comprised or a set of valid CSS `transition-timing-function` based on Cubic Bezier; EG: `cubic-bezier(0.215,0.61,0.355,1)` for `bezierEasings.easingCubicOut`;
278
- * ***mouseSwipeEvents*** - preserves the pointer events from mouse actions: start: `mousedown`, end: `mouseup`, move: `mousemove`, cancel: `mouseout`;
279
- * ***mouseClickEvents*** - preserves the pointer events from mouse actions: down: `mousedown`, up: `mouseup`;
280
- * ***mouseHoverEvents*** - preserve browser specific mouse hover events: `mouseenter` and `mouseleave` OR `mouseover` and `mouseout`;
281
- * ***touchEvents*** - preserves the pointer events from touch actions: start: `touchstart`, end: `touchend`, move: `touchmove`, cancel: `touchcancel`;
282
- * ***animationDuration*** - preserves the `animationDuration` property for modern browsers;
283
- * ***animationDurationLegacy*** - for legacy browsers fallback;
284
- * ***animationDelay*** - preserves the `animationDelay` property for modern browsers;
285
- * ***animationDelayLegacy*** - for legacy browsers fallback;
286
- * ***animationEndEvent*** - preserves the `animationEndEvent` event for modern browsers;
287
- * ***animationEndEventLegacy*** - for legacy browsers fallback;
288
- * ***animationName*** - preserves the `animationName` property name for modern browsers;
289
- * ***animationNameLegacy*** - for legacy browsers fallback;
290
- * ***transitionDuration*** - preserves the `transitionDuration` property name for modern browsers;
291
- * ***transitionDurationLegacy*** - for legacy browsers fallback;
292
- * ***transitionDelay*** - preserves the `transitionDelay` property name for modern browsers;
293
- * ***transitionDelayLegacy*** - for legacy browsers fallback;
294
- * ***transitionEndEvent*** - preserves the `transitionend` event name for modern browsers;
295
- * ***transitionEndEventLegacy*** - for legacy browsers fallback;
296
- * ***transitionProperty*** - preserves the `transitionProperty` property name for modern browsers;
297
- * ***transitionPropertyLegacy*** - for legacy browsers fallback;
298
- * ***addEventListener*** - preserves the `addEventListener` method name;
299
- * ***removeEventListener*** - preserves the `removeEventListener` method name;
279
+
280
+ - **_bezierEasings_** - an _Object_ comprised or a set of valid CSS `transition-timing-function` based on Cubic Bezier; EG: `cubic-bezier(0.215,0.61,0.355,1)` for `bezierEasings.easingCubicOut`;
281
+ - **_mouseSwipeEvents_** - preserves the pointer events from mouse actions: start: `mousedown`, end: `mouseup`, move: `mousemove`, cancel: `mouseout`;
282
+ - **_mouseClickEvents_** - preserves the pointer events from mouse actions: down: `mousedown`, up: `mouseup`;
283
+ - **_mouseHoverEvents_** - preserve browser specific mouse hover events: `mouseenter` and `mouseleave` OR `mouseover` and `mouseout`;
284
+ - **_touchEvents_** - preserves the pointer events from touch actions: start: `touchstart`, end: `touchend`, move: `touchmove`, cancel: `touchcancel`;
285
+ - **_animationDuration_** - preserves the `animationDuration` property for modern browsers;
286
+ - **_animationDelay_** - preserves the `animationDelay` property for modern browsers;
287
+ - **_animationEndEvent_** - preserves the `animationEndEvent` event for modern browsers;
288
+ - **_animationName_** - preserves the `animationName` property name for modern browsers;
289
+ - **_transitionDuration_** - preserves the `transitionDuration` property name for modern browsers;
290
+ - **_transitionDelay_** - preserves the `transitionDelay` property name for modern browsers;
291
+ - **_transitionEndEvent_** - preserves the `transitionend` event name for modern browsers;
292
+ - **_transitionProperty_** - preserves the `transitionProperty` property name for modern browsers;
293
+ - **_addEventListener_** - preserves the `addEventListener` method name;
294
+ - **_removeEventListener_** - preserves the `removeEventListener` method name;
300
295
 
301
296
  There are lots more string constants available which include native event names, browser strings, keyboard key codes or ARIA specific attribute names. Be sure to check the `src/strings` folder for a complete list.
302
297
 
303
- ```js
298
+ ```js
304
299
  // EXAMPLES
305
- import {on, off, one, mouseClickEvents, touchEvents, passiveHandler} from '@thednp/shorty';
300
+ import { on, off, one, mouseClickEvents, touchEvents, passiveHandler } from "@thednp/shorty";
306
301
 
307
302
  // attach a passive mousedown eventHandler
308
303
  on(targetElement, mouseClickEvents.down, eventHandler, passiveHandler);
@@ -315,32 +310,34 @@ one(targetElement, touchEvents.start, eventHandler, passiveHandler);
315
310
  ```
316
311
 
317
312
  # Advanced Use
318
- Here's a simple example to showcase the benefit of using ***shorty***.
313
+
314
+ Here's a simple example to showcase the benefit of using **_shorty_**.
319
315
 
320
316
  ```js
321
317
  // This is your typical day to day scripting
322
- const target = document.getElementById('my-element');
318
+ const target = document.getElementById("my-element");
323
319
 
324
- target.addEventListener('click', function(e) {
325
- target.classList.add('my-className');
326
- })
320
+ target.addEventListener("click", function (e) {
321
+ target.classList.add("my-className");
322
+ });
327
323
  ```
328
324
 
329
325
  Now make it all shorty. You might want to import shorties directly from their location, something we like to call "tree shaking".
326
+
330
327
  ```js
331
328
  // Example
332
- import on from '@thednp/shorty/src/event/on';
333
- import addClass from '@thednp/shorty/src/class/addClass';
334
- import getElementById from '@thednp/shorty/src/selectors/getElementById';
335
- import mouseclickEvent from '@thednp/shorty/src/strings/mouseclickEvent';
329
+ import on from "@thednp/shorty/src/event/on";
330
+ import addClass from "@thednp/shorty/src/class/addClass";
331
+ import getElementById from "@thednp/shorty/src/selectors/getElementById";
332
+ import mouseclickEvent from "@thednp/shorty/src/strings/mouseclickEvent";
336
333
 
337
- const target = getElementById('my-element');
334
+ const target = getElementById("my-element");
338
335
 
339
- on(target, mouseclickEvent, function(e) {
340
- addClass(target, 'my-className')
341
- })
336
+ on(target, mouseclickEvent, function (e) {
337
+ addClass(target, "my-className");
338
+ });
342
339
  ```
343
340
 
344
-
345
341
  # License
342
+
346
343
  **shorty** is released under the [MIT License](https://github.com/thednp/shorty/blob/master/LICENSE)
@@ -0,0 +1,46 @@
1
+ /// <reference types="cypress" />
2
+ // @ts-nocheck
3
+
4
+ // import SHORTY from '../../src/index';
5
+ import * as SHORTY from '../../src/index';
6
+
7
+ describe('Shorty Library Tests', () => {
8
+ before(() => {
9
+ cy.visit('cypress/test.html');
10
+ });
11
+
12
+ it('Test attr folder', () => {
13
+ const {
14
+ getAttribute,
15
+ setAttribute,
16
+ hasAttribute,
17
+ removeAttribute,
18
+ getAttributeNS,
19
+ setAttributeNS,
20
+ hasAttributeNS,
21
+ removeAttributeNS,
22
+ querySelector,
23
+ } = SHORTY;
24
+
25
+ cy
26
+ .get('.alert')
27
+ .should($element => {
28
+ const el = $element[0];
29
+ expect(getAttribute(el, 'class'), 'getAttribute').to.have.length.above(0);
30
+ setAttribute(el, 'data-att', 'momo');
31
+ expect(hasAttribute(el, 'data-att'), 'hasAttribute').to.be.true;
32
+ removeAttribute(el, 'data-att');
33
+ expect(hasAttribute(el, 'data-att'), 'hasAttribute').to.be.false;
34
+ });
35
+ cy.get('svg').should($svg => {
36
+ console.log(querySelector('svg'));
37
+ const svg = $svg[0] as HTMLElement;
38
+ const ns = 'http://www.w3.org/2000/svg';
39
+ expect(hasAttributeNS(ns, svg, 'transform'), 'hasAttributeNS').to.be.false;
40
+ setAttributeNS(ns, svg, 'transform', 'scale(0.99)');
41
+ expect(getAttributeNS(ns, svg, 'transform'), 'getAttributeNS').to.eq('scale(0.99)');
42
+ removeAttributeNS(ns, svg, 'transform');
43
+ expect(getAttributeNS(ns, svg, 'transform'), 'getAttributeNS').to.be.null;
44
+ });
45
+ });
46
+ });