@thednp/shorty 1.0.0 → 1.0.3

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 (116) hide show
  1. package/README.md +14 -8
  2. package/dist/shorty.esm.js +388 -329
  3. package/dist/shorty.esm.min.js +2 -2
  4. package/dist/shorty.js +401 -336
  5. package/dist/shorty.min.js +2 -2
  6. package/package.json +12 -3
  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 +2 -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 +12 -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 +12 -12
  49. package/src/index.js +12 -10
  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/isObject.js +8 -0
  66. package/src/is/isRTL.js +1 -1
  67. package/src/is/isSVGElement.js +4 -1
  68. package/src/is/isScaledElement.js +2 -0
  69. package/src/is/isShadowRoot.js +2 -5
  70. package/src/is/isString.js +2 -2
  71. package/src/is/isTableElement.js +5 -1
  72. package/src/is/isWindow.js +5 -5
  73. package/src/misc/ObjectEntries.js +7 -0
  74. package/src/misc/OriginalEvent.js +4 -2
  75. package/src/misc/createElement.js +3 -1
  76. package/src/misc/createElementNS.js +7 -3
  77. package/src/misc/data.js +16 -16
  78. package/src/misc/dispatchEvent.js +1 -1
  79. package/src/misc/emulateAnimationEnd.js +5 -2
  80. package/src/misc/emulateAnimationEndLegacy.js +9 -6
  81. package/src/misc/emulateTransitionEnd.js +5 -2
  82. package/src/misc/emulateTransitionEndLegacy.js +9 -6
  83. package/src/misc/focus.js +1 -2
  84. package/src/misc/normalizeOptions.js +2 -2
  85. package/src/misc/normalizeValue.js +8 -6
  86. package/src/misc/passiveHandlerLegacy.js +2 -1
  87. package/src/misc/reflow.js +1 -2
  88. package/src/misc/setElementStyle.js +12 -3
  89. package/src/misc/timer.js +16 -19
  90. package/src/misc/version.js +0 -1
  91. package/src/selectors/closest.js +3 -3
  92. package/src/selectors/getCustomElements.js +4 -6
  93. package/src/selectors/getElementById.js +6 -3
  94. package/src/selectors/getElementsByClassName.js +5 -5
  95. package/src/selectors/getElementsByTagName.js +5 -5
  96. package/src/selectors/matches.js +1 -1
  97. package/src/selectors/matchesLegacy.js +8 -8
  98. package/src/selectors/querySelector.js +10 -6
  99. package/src/selectors/querySelectorAll.js +5 -5
  100. package/src/strings/animationDelayLegacy.js +2 -1
  101. package/src/strings/animationDurationLegacy.js +2 -1
  102. package/src/strings/animationEndEventLegacy.js +2 -1
  103. package/src/strings/animationNameLegacy.js +2 -1
  104. package/src/strings/mouseHoverEvents.js +2 -1
  105. package/src/strings/transitionDelayLegacy.js +2 -1
  106. package/src/strings/transitionDurationLegacy.js +2 -1
  107. package/src/strings/transitionEndEventLegacy.js +2 -1
  108. package/src/strings/transitionPropertyLegacy.js +2 -2
  109. package/src/strings/userAgentData.js +0 -1
  110. package/types/index.d.ts +10 -5
  111. package/types/module/shorty.ts +3 -4
  112. package/types/shorty.d.ts +248 -249
  113. package/src/misc/tryWrapper.js +0 -11
  114. package/src/selectors/documentAll.js +0 -8
  115. package/src/selectors/elementNodes.js +0 -5
  116. package/src/selectors/parentNodes.js +0 -5
package/README.md CHANGED
@@ -1,13 +1,19 @@
1
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/@thednp/shorty)
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/@thednp/shorty.svg)](http://npm-stat.com/charts.html?package=@thednp/shorty)
6
+ [![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)
9
+
2
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.
3
11
 
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
12
 
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.
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.
9
14
 
10
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.
11
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.
12
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.
13
19
 
@@ -170,6 +176,7 @@ const duration = getElementAnimationDurationLegacy(target);
170
176
  * ***isMedia*** - check if a given value is an `SVGElement`, `HTMLImageElement` or `HTMLVideoElement` instance;
171
177
  * ***isNode*** - check if a given value is a `Node` instance;
172
178
  * ***isNodeList*** - check if a given value is a `NodeList` instance;
179
+ * ***isNumber*** - check if a given value is string;
173
180
  * ***isRTL*** - check if a given node is contained in a `<html dir="rtl">`;
174
181
  * ***isScaledElement*** - check if a given *Element* is affected by scale;
175
182
  * ***isShadowRoot*** - check if a given *Node* is a `ShadowRoot` instance;
@@ -208,6 +215,7 @@ if (isElementsArray(myValue)) {
208
215
  * ***noop*** - is your regular `() => {}` NOOP;
209
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
210
217
  * ***ObjectAssign*** - a shortie for `Object.assign()` method;
218
+ * ***ObjectEntries*** - a shortie for `Object.entries()` method;
211
219
  * ***ObjectKeys*** - a shortie for `Object.keys()` method;
212
220
  * ***ObjectValues*** - a shortie for `Object.values()` method;
213
221
  * ***OriginalEvent*** - a small utility that returns a synthetic `CustomEvent` with the added `relatedTarget` and other properties;
@@ -218,7 +226,6 @@ if (isElementsArray(myValue)) {
218
226
  * ***Timer*** - a small but powerful utility that makes `setTimeout` have a meaning;
219
227
  * ***toLowerCase*** - a shortie for `String.toLowerCase()` method;
220
228
  * ***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
229
 
223
230
  The ***Data*** and ***Timer*** utilities have their own specifics, you might want to check the [wiki](https://github.com/thednp/shorty/wiki).
224
231
 
@@ -227,7 +234,7 @@ The ***Data*** and ***Timer*** utilities have their own specifics, you might wan
227
234
  import {
228
235
  emulateTransitionEnd,
229
236
  distinct,
230
- } from 'shorty';
237
+ } from '@thednp/shorty';
231
238
 
232
239
  // execute a callback when transitionend is triggered for the target
233
240
  emulateTransitionEnd(targetElement, callback);
@@ -243,7 +250,6 @@ const array3 = [...array1, ...array2].filter(distinct);
243
250
 
244
251
  # selectors
245
252
  * ***closest*** - a shortie for `Element.closest()` method;
246
- * ***documentAll*** - a quick bit equivalent of the deprecated `document.all` collection;
247
253
  * ***getCustomElements*** - returns an `Array` with all registered `CustomElement`;
248
254
  * ***getElementById*** - a shortie for `document.getElementById()` method;
249
255
  * ***getElementsByClassName*** - a shortie for `Element.getElementsByClassName()` method;
@@ -255,7 +261,7 @@ const array3 = [...array1, ...array2].filter(distinct);
255
261
 
256
262
  ```js
257
263
  // EXAMPLES
258
- import { querySelector, querySelectorAll, documentAll, matches } from 'shorty';
264
+ import { querySelector, querySelectorAll, documentAll, matches } from '@thednp/shorty';
259
265
 
260
266
  // get first element that matches a certain selector
261
267
  const element = querySelector('.my-class-name');