@thednp/shorty 1.0.1 → 1.0.2

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 (113) hide show
  1. package/README.md +12 -7
  2. package/dist/shorty.esm.js +379 -312
  3. package/dist/shorty.esm.min.js +2 -2
  4. package/dist/shorty.js +392 -319
  5. package/dist/shorty.min.js +2 -2
  6. package/package.json +11 -2
  7. package/src/attr/getAttribute.js +1 -1
  8. package/src/attr/getAttributeNS.js +1 -1
  9. package/src/attr/hasAttribute.js +1 -1
  10. package/src/attr/hasAttributeNS.js +1 -1
  11. package/src/attr/removeAttribute.js +1 -1
  12. package/src/attr/removeAttributeNS.js +1 -1
  13. package/src/attr/setAttribute.js +1 -1
  14. package/src/attr/setAttributeNS.js +1 -1
  15. package/src/boolean/isApple.js +2 -2
  16. package/src/boolean/isFirefox.js +2 -1
  17. package/src/boolean/isMobile.js +2 -2
  18. package/src/boolean/support3DTransform.js +2 -1
  19. package/src/boolean/supportAnimation.js +2 -1
  20. package/src/boolean/supportPassive.js +1 -1
  21. package/src/boolean/supportTouch.js +2 -1
  22. package/src/boolean/supportTransform.js +2 -1
  23. package/src/boolean/supportTransition.js +2 -1
  24. package/src/class/addClass.js +1 -1
  25. package/src/class/hasClass.js +1 -1
  26. package/src/class/removeClass.js +1 -1
  27. package/src/event/off.js +2 -6
  28. package/src/event/on.js +2 -6
  29. package/src/event/one.js +3 -6
  30. package/src/get/getBoundingClientRect.js +9 -5
  31. package/src/get/getDocument.js +8 -3
  32. package/src/get/getDocumentBody.js +2 -2
  33. package/src/get/getDocumentElement.js +2 -2
  34. package/src/get/getDocumentHead.js +2 -2
  35. package/src/get/getElementAnimationDelay.js +3 -3
  36. package/src/get/getElementAnimationDelayLegacy.js +3 -3
  37. package/src/get/getElementAnimationDuration.js +3 -3
  38. package/src/get/getElementAnimationDurationLegacy.js +3 -3
  39. package/src/get/getElementStyle.js +5 -3
  40. package/src/get/getElementTransitionDelay.js +3 -4
  41. package/src/get/getElementTransitionDelayLegacy.js +3 -3
  42. package/src/get/getElementTransitionDuration.js +3 -3
  43. package/src/get/getElementTransitionDurationLegacy.js +3 -3
  44. package/src/get/getNodeScroll.js +1 -1
  45. package/src/get/getParentNode.js +4 -5
  46. package/src/get/getRectRelativeToOffsetParent.js +7 -5
  47. package/src/get/getUID.js +1 -1
  48. package/src/get/getWindow.js +16 -7
  49. package/src/index.js +10 -6
  50. package/src/is/isArray.js +0 -1
  51. package/src/is/isCustomElement.js +1 -1
  52. package/src/is/isDocument.js +3 -2
  53. package/src/is/isElement.js +14 -1
  54. package/src/is/isElementInScrollRange.js +4 -2
  55. package/src/is/isElementInViewport.js +6 -2
  56. package/src/is/isElementsArray.js +3 -1
  57. package/src/is/isFunction.js +2 -3
  58. package/src/is/isHTMLCollection.js +1 -1
  59. package/src/is/isHTMLElement.js +2 -1
  60. package/src/is/isHTMLImageElement.js +1 -1
  61. package/src/is/isMedia.js +5 -3
  62. package/src/is/isNode.js +2 -1
  63. package/src/is/isNodeList.js +2 -1
  64. package/src/is/isNumber.js +8 -0
  65. package/src/is/isRTL.js +1 -1
  66. package/src/is/isSVGElement.js +4 -1
  67. package/src/is/isScaledElement.js +2 -0
  68. package/src/is/isShadowRoot.js +2 -5
  69. package/src/is/isString.js +2 -2
  70. package/src/is/isTableElement.js +5 -1
  71. package/src/is/isWindow.js +5 -5
  72. package/src/misc/ObjectEntries.js +7 -0
  73. package/src/misc/OriginalEvent.js +2 -1
  74. package/src/misc/createElement.js +3 -1
  75. package/src/misc/createElementNS.js +7 -3
  76. package/src/misc/data.js +16 -16
  77. package/src/misc/dispatchEvent.js +1 -1
  78. package/src/misc/emulateAnimationEnd.js +5 -2
  79. package/src/misc/emulateAnimationEndLegacy.js +9 -6
  80. package/src/misc/emulateTransitionEnd.js +5 -2
  81. package/src/misc/emulateTransitionEndLegacy.js +9 -6
  82. package/src/misc/focus.js +1 -2
  83. package/src/misc/normalizeOptions.js +2 -2
  84. package/src/misc/normalizeValue.js +8 -6
  85. package/src/misc/passiveHandlerLegacy.js +2 -1
  86. package/src/misc/reflow.js +1 -2
  87. package/src/misc/setElementStyle.js +12 -3
  88. package/src/misc/timer.js +16 -19
  89. package/src/misc/version.js +0 -1
  90. package/src/selectors/closest.js +3 -3
  91. package/src/selectors/getCustomElements.js +4 -5
  92. package/src/selectors/getElementById.js +6 -3
  93. package/src/selectors/getElementsByClassName.js +4 -3
  94. package/src/selectors/getElementsByTagName.js +4 -3
  95. package/src/selectors/matches.js +1 -1
  96. package/src/selectors/matchesLegacy.js +8 -8
  97. package/src/selectors/querySelector.js +9 -7
  98. package/src/selectors/querySelectorAll.js +4 -3
  99. package/src/strings/animationDelayLegacy.js +2 -1
  100. package/src/strings/animationDurationLegacy.js +2 -1
  101. package/src/strings/animationEndEventLegacy.js +2 -1
  102. package/src/strings/animationNameLegacy.js +2 -1
  103. package/src/strings/mouseHoverEvents.js +2 -1
  104. package/src/strings/transitionDelayLegacy.js +2 -1
  105. package/src/strings/transitionDurationLegacy.js +2 -1
  106. package/src/strings/transitionEndEventLegacy.js +2 -1
  107. package/src/strings/transitionPropertyLegacy.js +2 -2
  108. package/src/strings/userAgentData.js +0 -1
  109. package/types/index.d.ts +9 -3
  110. package/types/module/shorty.ts +2 -2
  111. package/types/shorty.d.ts +237 -224
  112. package/src/misc/tryWrapper.js +0 -11
  113. package/src/selectors/documentAll.js +0 -8
package/README.md CHANGED
@@ -1,14 +1,19 @@
1
- # shorty ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen) [![ci](https://github.com/thednp/shorty/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/shorty/actions/workflows/ci.yml)
1
+ # shorty
2
+ [![Coverage Status](https://coveralls.io/repos/github/thednp/shorty/badge.svg)](https://coveralls.io/github/thednp/shorty)
3
+ [![ci](https://github.com/thednp/shorty/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/shorty/actions/workflows/ci.yml)
4
+ [![NPM Version](https://img.shields.io/npm/v/@thednp/shorty.svg)](https://www.npmjs.com/package/shorty)
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/shorty.svg)](http://npm-stat.com/charts.html?package=shorty)
6
+ ![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hw/@thednp/shorty)
7
+ ![cypress version](https://img.shields.io/badge/cypress-9.6.1-brightgreen)
8
+ ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
2
9
 
3
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.
4
11
 
5
- [![NPM Version](https://img.shields.io/npm/v/@thednp/shorty.svg?style=flat-square)](https://www.npmjs.com/package/shorty)
6
- [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/shorty.svg?style=flat-square)](http://npm-stat.com/charts.html?package=shorty)
7
- [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/@thednp/shorty/badge)](https://www.jsdelivr.com/package/npm/shorty)
8
12
 
9
- **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.
13
+ **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.
10
14
 
11
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.
12
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.
13
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.
14
19
 
@@ -171,6 +176,7 @@ const duration = getElementAnimationDurationLegacy(target);
171
176
  * ***isMedia*** - check if a given value is an `SVGElement`, `HTMLImageElement` or `HTMLVideoElement` instance;
172
177
  * ***isNode*** - check if a given value is a `Node` instance;
173
178
  * ***isNodeList*** - check if a given value is a `NodeList` instance;
179
+ * ***isNumber*** - check if a given value is string;
174
180
  * ***isRTL*** - check if a given node is contained in a `<html dir="rtl">`;
175
181
  * ***isScaledElement*** - check if a given *Element* is affected by scale;
176
182
  * ***isShadowRoot*** - check if a given *Node* is a `ShadowRoot` instance;
@@ -209,6 +215,7 @@ if (isElementsArray(myValue)) {
209
215
  * ***noop*** - is your regular `() => {}` NOOP;
210
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
211
217
  * ***ObjectAssign*** - a shortie for `Object.assign()` method;
218
+ * ***ObjectEntries*** - a shortie for `Object.entries()` method;
212
219
  * ***ObjectKeys*** - a shortie for `Object.keys()` method;
213
220
  * ***ObjectValues*** - a shortie for `Object.values()` method;
214
221
  * ***OriginalEvent*** - a small utility that returns a synthetic `CustomEvent` with the added `relatedTarget` and other properties;
@@ -219,7 +226,6 @@ if (isElementsArray(myValue)) {
219
226
  * ***Timer*** - a small but powerful utility that makes `setTimeout` have a meaning;
220
227
  * ***toLowerCase*** - a shortie for `String.toLowerCase()` method;
221
228
  * ***toUpperCase*** - a shortie for `String.toUpperCase()` method;
222
- * ***tryWrapper*** - a simple `try()` and `catch()` wrapper for functions, with option to preffix the error logs, pointing out the context of the errors;
223
229
 
224
230
  The ***Data*** and ***Timer*** utilities have their own specifics, you might want to check the [wiki](https://github.com/thednp/shorty/wiki).
225
231
 
@@ -244,7 +250,6 @@ const array3 = [...array1, ...array2].filter(distinct);
244
250
 
245
251
  # selectors
246
252
  * ***closest*** - a shortie for `Element.closest()` method;
247
- * ***documentAll*** - a quick bit equivalent of the deprecated `document.all` collection;
248
253
  * ***getCustomElements*** - returns an `Array` with all registered `CustomElement`;
249
254
  * ***getElementById*** - a shortie for `document.getElementById()` method;
250
255
  * ***getElementsByClassName*** - a shortie for `Element.getElementsByClassName()` method;