@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.
- package/README.md +14 -8
- package/dist/shorty.esm.js +388 -329
- package/dist/shorty.esm.min.js +2 -2
- package/dist/shorty.js +401 -336
- package/dist/shorty.min.js +2 -2
- package/package.json +12 -3
- package/src/attr/getAttribute.js +1 -1
- package/src/attr/getAttributeNS.js +1 -1
- package/src/attr/hasAttribute.js +1 -1
- package/src/attr/hasAttributeNS.js +1 -1
- package/src/attr/removeAttribute.js +1 -1
- package/src/attr/removeAttributeNS.js +1 -1
- package/src/attr/setAttribute.js +1 -1
- package/src/attr/setAttributeNS.js +1 -1
- package/src/boolean/isApple.js +2 -2
- package/src/boolean/isFirefox.js +2 -1
- package/src/boolean/isMobile.js +2 -2
- package/src/boolean/support3DTransform.js +2 -1
- package/src/boolean/supportAnimation.js +2 -1
- package/src/boolean/supportPassive.js +2 -1
- package/src/boolean/supportTouch.js +2 -1
- package/src/boolean/supportTransform.js +2 -1
- package/src/boolean/supportTransition.js +2 -1
- package/src/class/addClass.js +1 -1
- package/src/class/hasClass.js +1 -1
- package/src/class/removeClass.js +1 -1
- package/src/event/off.js +2 -6
- package/src/event/on.js +2 -6
- package/src/event/one.js +3 -6
- package/src/get/getBoundingClientRect.js +9 -5
- package/src/get/getDocument.js +12 -3
- package/src/get/getDocumentBody.js +2 -2
- package/src/get/getDocumentElement.js +2 -2
- package/src/get/getDocumentHead.js +2 -2
- package/src/get/getElementAnimationDelay.js +3 -3
- package/src/get/getElementAnimationDelayLegacy.js +3 -3
- package/src/get/getElementAnimationDuration.js +3 -3
- package/src/get/getElementAnimationDurationLegacy.js +3 -3
- package/src/get/getElementStyle.js +5 -3
- package/src/get/getElementTransitionDelay.js +3 -4
- package/src/get/getElementTransitionDelayLegacy.js +3 -3
- package/src/get/getElementTransitionDuration.js +3 -3
- package/src/get/getElementTransitionDurationLegacy.js +3 -3
- package/src/get/getNodeScroll.js +1 -1
- package/src/get/getParentNode.js +4 -5
- package/src/get/getRectRelativeToOffsetParent.js +7 -5
- package/src/get/getUID.js +1 -1
- package/src/get/getWindow.js +12 -12
- package/src/index.js +12 -10
- package/src/is/isArray.js +0 -1
- package/src/is/isCustomElement.js +1 -1
- package/src/is/isDocument.js +3 -2
- package/src/is/isElement.js +14 -1
- package/src/is/isElementInScrollRange.js +4 -2
- package/src/is/isElementInViewport.js +6 -2
- package/src/is/isElementsArray.js +3 -1
- package/src/is/isFunction.js +2 -3
- package/src/is/isHTMLCollection.js +1 -1
- package/src/is/isHTMLElement.js +2 -1
- package/src/is/isHTMLImageElement.js +1 -1
- package/src/is/isMedia.js +5 -3
- package/src/is/isNode.js +2 -1
- package/src/is/isNodeList.js +2 -1
- package/src/is/isNumber.js +8 -0
- package/src/is/isObject.js +8 -0
- package/src/is/isRTL.js +1 -1
- package/src/is/isSVGElement.js +4 -1
- package/src/is/isScaledElement.js +2 -0
- package/src/is/isShadowRoot.js +2 -5
- package/src/is/isString.js +2 -2
- package/src/is/isTableElement.js +5 -1
- package/src/is/isWindow.js +5 -5
- package/src/misc/ObjectEntries.js +7 -0
- package/src/misc/OriginalEvent.js +4 -2
- package/src/misc/createElement.js +3 -1
- package/src/misc/createElementNS.js +7 -3
- package/src/misc/data.js +16 -16
- package/src/misc/dispatchEvent.js +1 -1
- package/src/misc/emulateAnimationEnd.js +5 -2
- package/src/misc/emulateAnimationEndLegacy.js +9 -6
- package/src/misc/emulateTransitionEnd.js +5 -2
- package/src/misc/emulateTransitionEndLegacy.js +9 -6
- package/src/misc/focus.js +1 -2
- package/src/misc/normalizeOptions.js +2 -2
- package/src/misc/normalizeValue.js +8 -6
- package/src/misc/passiveHandlerLegacy.js +2 -1
- package/src/misc/reflow.js +1 -2
- package/src/misc/setElementStyle.js +12 -3
- package/src/misc/timer.js +16 -19
- package/src/misc/version.js +0 -1
- package/src/selectors/closest.js +3 -3
- package/src/selectors/getCustomElements.js +4 -6
- package/src/selectors/getElementById.js +6 -3
- package/src/selectors/getElementsByClassName.js +5 -5
- package/src/selectors/getElementsByTagName.js +5 -5
- package/src/selectors/matches.js +1 -1
- package/src/selectors/matchesLegacy.js +8 -8
- package/src/selectors/querySelector.js +10 -6
- package/src/selectors/querySelectorAll.js +5 -5
- package/src/strings/animationDelayLegacy.js +2 -1
- package/src/strings/animationDurationLegacy.js +2 -1
- package/src/strings/animationEndEventLegacy.js +2 -1
- package/src/strings/animationNameLegacy.js +2 -1
- package/src/strings/mouseHoverEvents.js +2 -1
- package/src/strings/transitionDelayLegacy.js +2 -1
- package/src/strings/transitionDurationLegacy.js +2 -1
- package/src/strings/transitionEndEventLegacy.js +2 -1
- package/src/strings/transitionPropertyLegacy.js +2 -2
- package/src/strings/userAgentData.js +0 -1
- package/types/index.d.ts +10 -5
- package/types/module/shorty.ts +3 -4
- package/types/shorty.d.ts +248 -249
- package/src/misc/tryWrapper.js +0 -11
- package/src/selectors/documentAll.js +0 -8
- package/src/selectors/elementNodes.js +0 -5
- package/src/selectors/parentNodes.js +0 -5
package/README.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
# shorty
|
|
2
|
+
[](https://coveralls.io/github/thednp/shorty)
|
|
3
|
+
[](https://github.com/thednp/shorty/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@thednp/shorty)
|
|
5
|
+
[](http://npm-stat.com/charts.html?package=@thednp/shorty)
|
|
6
|
+
[](https://www.jsdelivr.com/package/npm/@thednp/shorty)
|
|
7
|
+

|
|
8
|
+

|
|
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
|
-
[](https://www.npmjs.com/package/shorty)
|
|
5
|
-
[](http://npm-stat.com/charts.html?package=shorty)
|
|
6
|
-
[](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');
|