@thednp/shorty 1.0.0

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 (234) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +340 -0
  3. package/dist/shorty.esm.js +2540 -0
  4. package/dist/shorty.esm.min.js +2 -0
  5. package/dist/shorty.js +2563 -0
  6. package/dist/shorty.min.js +2 -0
  7. package/package.json +59 -0
  8. package/src/attr/getAttribute.js +9 -0
  9. package/src/attr/getAttributeNS.js +10 -0
  10. package/src/attr/hasAttribute.js +9 -0
  11. package/src/attr/hasAttributeNS.js +10 -0
  12. package/src/attr/removeAttribute.js +9 -0
  13. package/src/attr/removeAttributeNS.js +10 -0
  14. package/src/attr/setAttribute.js +10 -0
  15. package/src/attr/setAttributeNS.js +11 -0
  16. package/src/blocks/documentBody.js +5 -0
  17. package/src/blocks/documentElement.js +5 -0
  18. package/src/blocks/documentHead.js +5 -0
  19. package/src/boolean/isApple.js +13 -0
  20. package/src/boolean/isFirefox.js +9 -0
  21. package/src/boolean/isMobile.js +20 -0
  22. package/src/boolean/support3DTransform.js +8 -0
  23. package/src/boolean/supportAnimation.js +8 -0
  24. package/src/boolean/supportPassive.js +28 -0
  25. package/src/boolean/supportTouch.js +6 -0
  26. package/src/boolean/supportTransform.js +8 -0
  27. package/src/boolean/supportTransition.js +8 -0
  28. package/src/class/addClass.js +10 -0
  29. package/src/class/hasClass.js +10 -0
  30. package/src/class/removeClass.js +10 -0
  31. package/src/event/off.js +13 -0
  32. package/src/event/on.js +13 -0
  33. package/src/event/one.js +26 -0
  34. package/src/get/getBoundingClientRect.js +33 -0
  35. package/src/get/getDocument.js +11 -0
  36. package/src/get/getDocumentBody.js +10 -0
  37. package/src/get/getDocumentElement.js +11 -0
  38. package/src/get/getDocumentHead.js +10 -0
  39. package/src/get/getElementAnimationDelay.js +21 -0
  40. package/src/get/getElementAnimationDelayLegacy.js +21 -0
  41. package/src/get/getElementAnimationDuration.js +20 -0
  42. package/src/get/getElementAnimationDurationLegacy.js +21 -0
  43. package/src/get/getElementStyle.js +18 -0
  44. package/src/get/getElementTransitionDelay.js +21 -0
  45. package/src/get/getElementTransitionDelayLegacy.js +21 -0
  46. package/src/get/getElementTransitionDuration.js +20 -0
  47. package/src/get/getElementTransitionDurationLegacy.js +21 -0
  48. package/src/get/getNodeScroll.js +16 -0
  49. package/src/get/getParentNode.js +24 -0
  50. package/src/get/getRectRelativeToOffsetParent.js +30 -0
  51. package/src/get/getUID.js +34 -0
  52. package/src/get/getWindow.js +20 -0
  53. package/src/index.js +475 -0
  54. package/src/is/isArray.js +9 -0
  55. package/src/is/isCustomElement.js +8 -0
  56. package/src/is/isDocument.js +9 -0
  57. package/src/is/isElement.js +9 -0
  58. package/src/is/isElementInScrollRange.js +18 -0
  59. package/src/is/isElementInViewport.js +22 -0
  60. package/src/is/isElementsArray.js +10 -0
  61. package/src/is/isFunction.js +9 -0
  62. package/src/is/isHTMLCollection.js +8 -0
  63. package/src/is/isHTMLElement.js +8 -0
  64. package/src/is/isHTMLImageElement.js +8 -0
  65. package/src/is/isMedia.js +12 -0
  66. package/src/is/isNode.js +8 -0
  67. package/src/is/isNodeList.js +8 -0
  68. package/src/is/isRTL.js +9 -0
  69. package/src/is/isSVGElement.js +8 -0
  70. package/src/is/isScaledElement.js +15 -0
  71. package/src/is/isShadowRoot.js +12 -0
  72. package/src/is/isString.js +8 -0
  73. package/src/is/isTableElement.js +7 -0
  74. package/src/is/isWindow.js +9 -0
  75. package/src/misc/ArrayFrom.js +8 -0
  76. package/src/misc/Float32ArrayFrom.js +7 -0
  77. package/src/misc/Float64ArrayFrom.js +7 -0
  78. package/src/misc/ObjectAssign.js +7 -0
  79. package/src/misc/ObjectKeys.js +7 -0
  80. package/src/misc/ObjectValues.js +7 -0
  81. package/src/misc/OriginalEvent.js +18 -0
  82. package/src/misc/createElement.js +25 -0
  83. package/src/misc/createElementNS.js +26 -0
  84. package/src/misc/data.js +78 -0
  85. package/src/misc/dispatchEvent.js +8 -0
  86. package/src/misc/distinct.js +10 -0
  87. package/src/misc/emulateAnimationEnd.js +37 -0
  88. package/src/misc/emulateAnimationEndLegacy.js +38 -0
  89. package/src/misc/emulateTransitionEnd.js +37 -0
  90. package/src/misc/emulateTransitionEndLegacy.js +38 -0
  91. package/src/misc/focus.js +8 -0
  92. package/src/misc/noop.js +3 -0
  93. package/src/misc/normalizeOptions.js +49 -0
  94. package/src/misc/normalizeValue.js +32 -0
  95. package/src/misc/passiveHandler.js +7 -0
  96. package/src/misc/passiveHandlerLegacy.js +9 -0
  97. package/src/misc/reflow.js +9 -0
  98. package/src/misc/setElementStyle.js +10 -0
  99. package/src/misc/timer.js +78 -0
  100. package/src/misc/toLowerCase.js +8 -0
  101. package/src/misc/toUpperCase.js +8 -0
  102. package/src/misc/tryWrapper.js +11 -0
  103. package/src/misc/version.js +9 -0
  104. package/src/selectors/closest.js +16 -0
  105. package/src/selectors/documentAll.js +8 -0
  106. package/src/selectors/elementNodes.js +5 -0
  107. package/src/selectors/getCustomElements.js +18 -0
  108. package/src/selectors/getElementById.js +11 -0
  109. package/src/selectors/getElementsByClassName.js +15 -0
  110. package/src/selectors/getElementsByTagName.js +15 -0
  111. package/src/selectors/matches.js +10 -0
  112. package/src/selectors/matchesLegacy.js +23 -0
  113. package/src/selectors/parentNodes.js +5 -0
  114. package/src/selectors/querySelector.js +15 -0
  115. package/src/selectors/querySelectorAll.js +14 -0
  116. package/src/strings/DOMContentLoadedEvent.js +6 -0
  117. package/src/strings/DOMMouseScrollEvent.js +6 -0
  118. package/src/strings/abortEvent.js +6 -0
  119. package/src/strings/addEventListener.js +6 -0
  120. package/src/strings/animationDelay.js +6 -0
  121. package/src/strings/animationDelayLegacy.js +8 -0
  122. package/src/strings/animationDuration.js +6 -0
  123. package/src/strings/animationDurationLegacy.js +8 -0
  124. package/src/strings/animationEndEvent.js +6 -0
  125. package/src/strings/animationEndEventLegacy.js +8 -0
  126. package/src/strings/animationName.js +6 -0
  127. package/src/strings/animationNameLegacy.js +8 -0
  128. package/src/strings/ariaChecked.js +6 -0
  129. package/src/strings/ariaDescribedBy.js +6 -0
  130. package/src/strings/ariaDescription.js +6 -0
  131. package/src/strings/ariaExpanded.js +6 -0
  132. package/src/strings/ariaHasPopup.js +6 -0
  133. package/src/strings/ariaHidden.js +6 -0
  134. package/src/strings/ariaLabel.js +6 -0
  135. package/src/strings/ariaLabelledBy.js +6 -0
  136. package/src/strings/ariaModal.js +6 -0
  137. package/src/strings/ariaPressed.js +6 -0
  138. package/src/strings/ariaSelected.js +6 -0
  139. package/src/strings/ariaValueMax.js +6 -0
  140. package/src/strings/ariaValueMin.js +6 -0
  141. package/src/strings/ariaValueNow.js +6 -0
  142. package/src/strings/ariaValueText.js +6 -0
  143. package/src/strings/beforeunloadEvent.js +6 -0
  144. package/src/strings/bezierEasings.js +33 -0
  145. package/src/strings/blurEvent.js +6 -0
  146. package/src/strings/changeEvent.js +6 -0
  147. package/src/strings/contextmenuEvent.js +6 -0
  148. package/src/strings/errorEvent.js +6 -0
  149. package/src/strings/focusEvent.js +6 -0
  150. package/src/strings/focusEvents.js +6 -0
  151. package/src/strings/focusinEvent.js +6 -0
  152. package/src/strings/focusoutEvent.js +6 -0
  153. package/src/strings/gesturechangeEvent.js +6 -0
  154. package/src/strings/gestureendEvent.js +6 -0
  155. package/src/strings/gesturestartEvent.js +6 -0
  156. package/src/strings/keyAlt.js +7 -0
  157. package/src/strings/keyArrowDown.js +7 -0
  158. package/src/strings/keyArrowLeft.js +7 -0
  159. package/src/strings/keyArrowRight.js +7 -0
  160. package/src/strings/keyArrowUp.js +7 -0
  161. package/src/strings/keyBackspace.js +7 -0
  162. package/src/strings/keyCapsLock.js +7 -0
  163. package/src/strings/keyControl.js +7 -0
  164. package/src/strings/keyDelete.js +7 -0
  165. package/src/strings/keyEnter.js +7 -0
  166. package/src/strings/keyEscape.js +7 -0
  167. package/src/strings/keyInsert.js +7 -0
  168. package/src/strings/keyMeta.js +7 -0
  169. package/src/strings/keyPause.js +7 -0
  170. package/src/strings/keyScrollLock.js +7 -0
  171. package/src/strings/keyShift.js +7 -0
  172. package/src/strings/keySpace.js +7 -0
  173. package/src/strings/keyTab.js +7 -0
  174. package/src/strings/keyboardEventKeys.js +27 -0
  175. package/src/strings/keydownEvent.js +6 -0
  176. package/src/strings/keypressEvent.js +6 -0
  177. package/src/strings/keyupEvent.js +6 -0
  178. package/src/strings/loadEvent.js +6 -0
  179. package/src/strings/loadstartEvent.js +6 -0
  180. package/src/strings/mouseClickEvents.js +6 -0
  181. package/src/strings/mouseHoverEvents.js +6 -0
  182. package/src/strings/mouseSwipeEvents.js +8 -0
  183. package/src/strings/mouseclickEvent.js +6 -0
  184. package/src/strings/mousedblclickEvent.js +6 -0
  185. package/src/strings/mousedownEvent.js +6 -0
  186. package/src/strings/mouseenterEvent.js +6 -0
  187. package/src/strings/mousehoverEvent.js +6 -0
  188. package/src/strings/mouseinEvent.js +6 -0
  189. package/src/strings/mouseleaveEvent.js +6 -0
  190. package/src/strings/mousemoveEvent.js +6 -0
  191. package/src/strings/mouseoutEvent.js +6 -0
  192. package/src/strings/mouseoverEvent.js +6 -0
  193. package/src/strings/mouseupEvent.js +6 -0
  194. package/src/strings/mousewheelEvent.js +6 -0
  195. package/src/strings/moveEvent.js +6 -0
  196. package/src/strings/nativeEvents.js +108 -0
  197. package/src/strings/offsetHeight.js +6 -0
  198. package/src/strings/offsetWidth.js +6 -0
  199. package/src/strings/orientationchangeEvent.js +6 -0
  200. package/src/strings/pointercancelEvent.js +6 -0
  201. package/src/strings/pointerdownEvent.js +6 -0
  202. package/src/strings/pointerleaveEvent.js +6 -0
  203. package/src/strings/pointermoveEvent.js +6 -0
  204. package/src/strings/pointerupEvent.js +6 -0
  205. package/src/strings/readystatechangeEvent.js +6 -0
  206. package/src/strings/removeEventListener.js +6 -0
  207. package/src/strings/resetEvent.js +6 -0
  208. package/src/strings/resizeEvent.js +6 -0
  209. package/src/strings/scrollEvent.js +6 -0
  210. package/src/strings/scrollHeight.js +6 -0
  211. package/src/strings/scrollWidth.js +6 -0
  212. package/src/strings/selectEvent.js +6 -0
  213. package/src/strings/selectendEvent.js +6 -0
  214. package/src/strings/selectstartEvent.js +6 -0
  215. package/src/strings/submitEvent.js +6 -0
  216. package/src/strings/touchEvents.js +8 -0
  217. package/src/strings/touchcancelEvent.js +6 -0
  218. package/src/strings/touchendEvent.js +6 -0
  219. package/src/strings/touchmoveEvent.js +6 -0
  220. package/src/strings/touchstartEvent.js +6 -0
  221. package/src/strings/transitionDelay.js +6 -0
  222. package/src/strings/transitionDelayLegacy.js +8 -0
  223. package/src/strings/transitionDuration.js +6 -0
  224. package/src/strings/transitionDurationLegacy.js +8 -0
  225. package/src/strings/transitionEndEvent.js +6 -0
  226. package/src/strings/transitionEndEventLegacy.js +8 -0
  227. package/src/strings/transitionProperty.js +7 -0
  228. package/src/strings/transitionPropertyLegacy.js +12 -0
  229. package/src/strings/unloadEvent.js +6 -0
  230. package/src/strings/userAgent.js +7 -0
  231. package/src/strings/userAgentData.js +8 -0
  232. package/types/index.d.ts +252 -0
  233. package/types/module/shorty.ts +249 -0
  234. package/types/shorty.d.ts +2317 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 thednp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ # shorty
2
+ 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.
3
+
4
+ [![NPM Version](https://img.shields.io/npm/v/@thednp/shorty.svg?style=flat-square)](https://www.npmjs.com/package/shorty)
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/shorty.svg?style=flat-square)](http://npm-stat.com/charts.html?package=shorty)
6
+ [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/@thednp/shorty/badge)](https://www.jsdelivr.com/package/npm/shorty)
7
+
8
+ **shorty** is featured in [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.
9
+
10
+ * 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.
11
+ * 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.
12
+ * 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.
13
+
14
+ # npm
15
+ ```
16
+ npm install @thednp/shorty
17
+ ```
18
+
19
+ # ES6+ Base usage
20
+ ```js
21
+ // import the tool you need
22
+ import { supportTransform } from '@thednp/shorty';
23
+
24
+ // use the tool in your ES6/ES7 sources
25
+ if (supportTransform) {
26
+ // have modern browsers do something about that
27
+ }
28
+ ```
29
+
30
+ # attr
31
+ * ***getAttribute*** - returns the value of a specified *Element* attribute;
32
+ * ***getAttributeNS*** - returns the value of a specified namespaced *Element* attribute (eg: namespaced SVG attributes);
33
+ * ***hasAttribute*** - check if element has a specified attribute;
34
+ * ***hasAttributeNS*** - check if element has a specified namespaced attribute;
35
+ * ***removeAttribute*** - removes a specified attribute from an element;
36
+ * ***removeAttributeNS*** - removes a specified namespaced attribute from an element;
37
+ * ***setAttribute*** - set a new attribute value for a given element;
38
+ * ***setAttributeNS*** - set a new namespaced attribute value for a given element;
39
+
40
+ ```js
41
+ // EXAMPLES
42
+ import { getAttribute, hasAttribute, setAttribute } from '@thednp/shorty';
43
+
44
+ // check target has certain attribute
45
+ if (!hasAttribute(myTarget, 'attribute-name')) {
46
+ setAttribute(myTarget, 'attribute-name', 'new-value');
47
+ }
48
+
49
+ // get attribute value
50
+ const currentAttrValue = getAttribute(myTarget, 'attribute-name');
51
+ ```
52
+
53
+
54
+ # blocks
55
+ * ***documentBody*** - a shortie for `document.body`;
56
+ * ***documentElement*** - a shortie for `document.documentElement`;
57
+ * ***documentHead*** - a shortie for `document.head`;
58
+
59
+ # boolean
60
+ * ***isApple*** - checks and preserves a `boolean` value for the client browser is either Apple **Safari** browser or not;
61
+ * ***isFirefox*** - checks and preserves a `boolean` value for the client browser is either **Firefox** or not;
62
+ * ***isMobile*** - checks and preserves a `boolean` value for the client browser is either a Mobile device or not;
63
+ * ***support3DTransform*** - checks and preserves a `boolean` value for the client browser capability for webKit `perspective`;
64
+ * ***supportTouch*** - checks and preserves a `boolean` value for the client browser capability for `touch` events;
65
+ * ***supportPassive*** - checks and preserves a `boolean` value for the client browser capability for `passive` event option;
66
+ * ***supportTransform*** - checks and preserves a `boolean` value for the client browser capability for webKit `transform`;
67
+ * ***supportAnimation*** - checks and preserves a `boolean` value for the client browser capability for webKit keyframe `animation`;
68
+ * ***supportTransition*** - checks and preserves a `boolean` value for the client browser capability for webKit `transition`;
69
+
70
+ ```js
71
+ // EXAMPLES
72
+ import { support3DTransform } from '@thednp/shorty';
73
+
74
+ // filter myAction to supported browsers
75
+ if (support3DTransform) {
76
+ // do something with modern browsers
77
+ }
78
+ ```
79
+
80
+ # class
81
+ * ***addClass*** - add a class to a target *Element*;
82
+ * ***removeClass*** - remove a class from a target *Element*;
83
+ * ***hasClass*** - checks the existence of a class for a target *Element*;
84
+
85
+ ```js
86
+ // EXAMPLES
87
+ import { addClass, removeClass, hasClass } from '@thednp/shorty'
88
+
89
+ // add a class
90
+ addClass(targetElement, 'className');
91
+
92
+ // remove a class
93
+ removeClass(targetElement, 'className');
94
+
95
+ // check for a class
96
+ if (hasClass(targetElement, 'className')) {
97
+ // do something about that
98
+ }
99
+ ```
100
+
101
+ # event
102
+ * ***on*** - attach an event listener to a specific target *Element*;
103
+ * ***off*** - detach an event listener from a specific target *Element*;
104
+ * ***one*** - attach an event listener to a specific target *Element*, and detach when complete;
105
+
106
+ ```js
107
+ // EXAMPLES
108
+ import { on, off, one, passiveHandler } from '@thednp/shorty';
109
+
110
+ // attach a passive mousedown eventHandler
111
+ on(targetElement, 'click', eventHandler, passiveHandler);
112
+
113
+ // detach a passive mouseup eventHandler
114
+ off(targetElement, 'mouseup', eventHandler, passiveHandler);
115
+
116
+ // attach a single instance passive touchstart eventHandler
117
+ one(targetElement, 'touchstart', eventHandler, passiveHandler);
118
+ ```
119
+
120
+ For a more advanced method to handle event listeners, I recommend using the [event-listener.js](github.com/thednp/event-listener.js).
121
+
122
+
123
+ # get
124
+ * ***getBoundingClientRect*** - returns the bounding client rectangle of a given *Element*;
125
+ * ***getDocument*** - returns the containing `#Document` for a given *Element* or just any *Document*, useful when working with *iframe*s;
126
+ * ***getDocumentBody*** - returns the containing `<body>` for a given *Element* or just any;
127
+ * ***getDocumentElement*** - returns the containing `<html>` for a given *Element* or just any;
128
+ * ***getDocumentHead*** - returns the containing `<head>` for a given *Element* or just any;
129
+ * ***getElementAnimationDelay*** - returns the `animationDelay` property of an `animation` property;
130
+ * ***getElementAnimationDelayLegacy*** - for legacy browsers;
131
+ * ***getElementAnimationDuration*** - returns the `animationDuration` property of a `animation` property;
132
+ * ***getElementAnimationDurationLegacy*** - for legacy browsers;
133
+ * ***getElementTransitionDelay*** - returns the `transitionDelay` property of a `transition` property;
134
+ * ***getElementTransitionDelayLegacy*** - for legacy browsers;
135
+ * ***getElementTransitionDuration*** - returns the `transitionDuration` property of a `transition` property;
136
+ * ***getElementTransitionDurationLegacy*** - for legacy browsers;
137
+ * ***getElementStyle*** - returns the *Element* computed style for a given property;
138
+ * ***getNodeScroll*** - returns the *Element* / *Window* current `{ x, y }` scroll position;
139
+ * ***getParentNode*** - returns parent of a given *Element*;
140
+ * ***getRectRelativeToOffsetParent*** - returns the bounding client rectangle of a given *Element* relative to a given `offsetParent`;
141
+ * ***getUID*** - a nice utility that creates a unique ID for a given *Element* and returns it;
142
+ * ***getWindow*** - returns the containing `Window` for a given *Element* or just any *Window*;
143
+
144
+ ```js
145
+ // EXAMPLES
146
+ import {
147
+ getElementAnimationDuration,
148
+ getElementAnimationDurationLegacy,
149
+ } from '@thednp/shorty'
150
+
151
+ // store the transition duration for target element on a modern browser
152
+ const duration = getElementAnimationDuration(target);
153
+
154
+ // or do the same with legacy browser fallback
155
+ const duration = getElementAnimationDurationLegacy(target);
156
+ ```
157
+
158
+ # is
159
+ * ***isArray*** - check if a given value is an `Array`;
160
+ * ***isCustomElement*** - check if a given value is a `CustomElement` instance;
161
+ * ***isDocument*** - check if a given value is a `Document` instance;
162
+ * ***isElement*** - check if a given value is an `Element` instance;
163
+ * ***isElementInScrollRange*** - check if a given `Element` is partially visible in the viewport;
164
+ * ***isElementInViewport*** - check if a given `Element` is fully visible in the viewport;
165
+ * ***isElementsArray*** - check if a given value is an `Array` with `Element` instances;
166
+ * ***isFunction*** - check if a given value is a `Function` instance;
167
+ * ***isHTMLCollection*** - check if a given value is an `HTMLCollection` instance;
168
+ * ***isHTMLElement*** - check if a given value is an `HTMLElement` instance;
169
+ * ***isHTMLImageElement*** - check if a given value is an `HTMLImageElement` instance;
170
+ * ***isMedia*** - check if a given value is an `SVGElement`, `HTMLImageElement` or `HTMLVideoElement` instance;
171
+ * ***isNode*** - check if a given value is a `Node` instance;
172
+ * ***isNodeList*** - check if a given value is a `NodeList` instance;
173
+ * ***isRTL*** - check if a given node is contained in a `<html dir="rtl">`;
174
+ * ***isScaledElement*** - check if a given *Element* is affected by scale;
175
+ * ***isShadowRoot*** - check if a given *Node* is a `ShadowRoot` instance;
176
+ * ***isString*** - check if a given value is string;
177
+ * ***isSVGElement*** - check if a given value is `SVGElement` instance;
178
+ * ***isTableElement*** - check if a given value is `<table>`, `<td>` or `<th>` *Element*;
179
+ * ***isWindow*** - check if a given value is a `Window` instance;
180
+
181
+ ```js
182
+ // EXAMPLES
183
+ import { isArray, isHTMLElement, isElementsArray } from '@thednp/shorty';
184
+
185
+ // check if a value is an `Array` of `Element` instances
186
+ if (isArray(myValue) && myValue.every(isHTMLElement)) {
187
+ // do something with these instances
188
+ }
189
+
190
+ // or use the dedicated shortie of the above
191
+ if (isElementsArray(myValue)) {
192
+ // do something with these instances
193
+ }
194
+ ```
195
+
196
+ # misc
197
+ * ***ArrayFrom*** - a shortie for `Array.from()` method;
198
+ * ***Data*** - a small utility to store web components data that makes use of the native `Map`;
199
+ * ***dispatchEvent*** - a shortie for `Element.dispatchEvent()` method;
200
+ * ***distinct*** - a shortie you can use to filter duplicate values in an `Array`;
201
+ * ***emulateAnimationEnd*** - utility to execute a callback function when `animationend` event is triggered, or execute the callback right after for legacy browsers;
202
+ * ***emulateAnimationEndLegacy*** - for legacy browsers;
203
+ * ***emulateTransitionEnd*** - utility to execute a callback function when `transitionend` event is triggered, or execute the callback right after for legacy browsers;
204
+ * ***emulateTransitionEndLegacy*** - for legacy browsers;
205
+ * ***Float32ArrayFrom*** - a shortie for `Float32Array.from()` method;
206
+ * ***Float64ArrayFrom*** - a shortie for `Float64Array.from()` method;
207
+ * ***focus*** - a shortie for `Element.focus()` method;
208
+ * ***noop*** - is your regular `() => {}` NOOP;
209
+ * ***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
210
+ * ***ObjectAssign*** - a shortie for `Object.assign()` method;
211
+ * ***ObjectKeys*** - a shortie for `Object.keys()` method;
212
+ * ***ObjectValues*** - a shortie for `Object.values()` method;
213
+ * ***OriginalEvent*** - a small utility that returns a synthetic `CustomEvent` with the added `relatedTarget` and other properties;
214
+ * ***passiveHandler*** - a constant that preserves a standard listener `options` with `passive: true` event option used;
215
+ * ***passiveHandlerLegacy*** - for legacy browsers;
216
+ * ***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;
217
+ * ***setElementStyle*** - a small utility that allows you to set multiple CSS properties at once for a given *Element* target;
218
+ * ***Timer*** - a small but powerful utility that makes `setTimeout` have a meaning;
219
+ * ***toLowerCase*** - a shortie for `String.toLowerCase()` method;
220
+ * ***toUpperCase*** - a shortie for `String.toUpperCase()` method;
221
+ * ***tryWrapper*** - a simple `try()` and `catch()` wrapper for functions, with option to preffix the error logs, pointing out the context of the errors;
222
+
223
+ The ***Data*** and ***Timer*** utilities have their own specifics, you might want to check the [wiki](https://github.com/thednp/shorty/wiki).
224
+
225
+ ```js
226
+ // EXAMPLES
227
+ import {
228
+ emulateTransitionEnd,
229
+ distinct,
230
+ } from 'shorty';
231
+
232
+ // execute a callback when transitionend is triggered for the target
233
+ emulateTransitionEnd(targetElement, callback);
234
+
235
+ // define some arrays of numbers
236
+ const array1 = [0, 1, 3, 5, 7, 9];
237
+ const array2 = [0, 2, 4, 6, 8, 10];
238
+
239
+ // merge them and filter them to make sure we have distinct values
240
+ const array3 = [...array1, ...array2].filter(distinct);
241
+ // [0, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
242
+ ```
243
+
244
+ # selectors
245
+ * ***closest*** - a shortie for `Element.closest()` method;
246
+ * ***documentAll*** - a quick bit equivalent of the deprecated `document.all` collection;
247
+ * ***getCustomElements*** - returns an `Array` with all registered `CustomElement`;
248
+ * ***getElementById*** - a shortie for `document.getElementById()` method;
249
+ * ***getElementsByClassName*** - a shortie for `Element.getElementsByClassName()` method;
250
+ * ***getElementsByTagName*** - a shortie for `Element.getElementsByTagName()` method;
251
+ * ***matches*** - a shortie for `Element.matches()` method;
252
+ * ***matchesLegacy*** - for legacy browsers;
253
+ * ***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;
254
+ * ***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;
255
+
256
+ ```js
257
+ // EXAMPLES
258
+ import { querySelector, querySelectorAll, documentAll, matches } from 'shorty';
259
+
260
+ // get first element that matches a certain selector
261
+ const element = querySelector('.my-class-name');
262
+
263
+ // get all elements that matches same selector
264
+ const elements = querySelectorAll('.my-class-name');
265
+
266
+ // now do the same as the above, but differently
267
+ const elements = [...documentAll].filter((x) => matches(x, '.my-class-name'));
268
+ ```
269
+
270
+ # strings
271
+ * ***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`;
272
+ * ***mouseSwipeEvents*** - preserves the pointer events from mouse actions: start: `mousedown`, end: `mouseup`, move: `mousemove`, cancel: `mouseout`;
273
+ * ***mouseClickEvents*** - preserves the pointer events from mouse actions: down: `mousedown`, up: `mouseup`;
274
+ * ***mouseHoverEvents*** - preserve browser specific mouse hover events: `mouseenter` and `mouseleave` OR `mouseover` and `mouseout`;
275
+ * ***touchEvents*** - preserves the pointer events from touch actions: start: `touchstart`, end: `touchend`, move: `touchmove`, cancel: `touchcancel`;
276
+ * ***animationDuration*** - preserves the `animationDuration` property for modern browsers;
277
+ * ***animationDurationLegacy*** - for legacy browsers fallback;
278
+ * ***animationDelay*** - preserves the `animationDelay` property for modern browsers;
279
+ * ***animationDelayLegacy*** - for legacy browsers fallback;
280
+ * ***animationEndEvent*** - preserves the `animationEndEvent` event for modern browsers;
281
+ * ***animationEndEventLegacy*** - for legacy browsers fallback;
282
+ * ***animationName*** - preserves the `animationName` property name for modern browsers;
283
+ * ***animationNameLegacy*** - for legacy browsers fallback;
284
+ * ***transitionDuration*** - preserves the `transitionDuration` property name for modern browsers;
285
+ * ***transitionDurationLegacy*** - for legacy browsers fallback;
286
+ * ***transitionDelay*** - preserves the `transitionDelay` property name for modern browsers;
287
+ * ***transitionDelayLegacy*** - for legacy browsers fallback;
288
+ * ***transitionEndEvent*** - preserves the `transitionend` event name for modern browsers;
289
+ * ***transitionEndEventLegacy*** - for legacy browsers fallback;
290
+ * ***transitionProperty*** - preserves the `transitionProperty` property name for modern browsers;
291
+ * ***transitionPropertyLegacy*** - for legacy browsers fallback;
292
+ * ***addEventListener*** - preserves the `addEventListener` method name;
293
+ * ***removeEventListener*** - preserves the `removeEventListener` method name;
294
+
295
+ 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.
296
+
297
+ ```js
298
+ // EXAMPLES
299
+ import {on, off, one, mouseClickEvents, touchEvents, passiveHandler} from '@thednp/shorty';
300
+
301
+ // attach a passive mousedown eventHandler
302
+ on(targetElement, mouseClickEvents.down, eventHandler, passiveHandler);
303
+
304
+ // detach a passive mousedown eventHandler
305
+ off(targetElement, mouseClickEvents.down, eventHandler, passiveHandler);
306
+
307
+ // attach a single instance passive touchstart eventHandler
308
+ one(targetElement, touchEvents.start, eventHandler, passiveHandler);
309
+ ```
310
+
311
+ # Advanced Use
312
+ Here's a simple example to showcase the benefit of using ***shorty***.
313
+
314
+ ```js
315
+ // This is your typical day to day scripting
316
+ const target = document.getElementById('my-element');
317
+
318
+ target.addEventListener('click', function(e) {
319
+ target.classList.add('my-className');
320
+ })
321
+ ```
322
+
323
+ Now make it all shorty. You might want to import shorties directly from their location, something we like to call "tree shaking".
324
+ ```js
325
+ // Example
326
+ import on from '@thednp/shorty/src/event/on';
327
+ import addClass from '@thednp/shorty/src/class/addClass';
328
+ import getElementById from '@thednp/shorty/src/selectors/getElementById';
329
+ import mouseclickEvent from '@thednp/shorty/src/strings/mouseclickEvent';
330
+
331
+ const target = getElementById('my-element');
332
+
333
+ on(target, mouseclickEvent, function(e) {
334
+ addClass(target, 'my-className')
335
+ })
336
+ ```
337
+
338
+
339
+ # License
340
+ **shorty** is released under the [MIT License](https://github.com/thednp/shorty/blob/master/LICENSE)