Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

matt-utils

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matt-utils - npm Package Compare versions

Comparing version 1.4.3 to 1.4.6

babel.config.cjs

90

dist/matt-utils.d.ts

@@ -5,19 +5,19 @@ declare module "matt-utils" {

*/
export type foreachCB = (value: Element, index?: number | undefined) => any;
export type foreachCB = (value: Element | HTMLElement, index?: number | undefined) => any;
/**
* Shorthand for `element.classList.add`, works with multiple nodes
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to add
*/
export function addClass(el: Element | HTMLCollection | NodeList, ...classes: string[]): void;
export function addClass(el: Element | HTMLElement | HTMLCollection | NodeList, ...classes: string[]): void;
/**
* Shorthand for `element.addEventListener`
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options
*/
export function addEvent(el: Element | HTMLCollection | NodeList, ev: string, fn: Function, opts?: Object | undefined): void;
export function addEvent(el: Element | HTMLElement | Window | Document | MediaQueryList, ev: string, fn: EventListenerOrEventListenerObject, opts?: Object | undefined): void;
/**

@@ -27,7 +27,7 @@ * Shorthand for `document.getElementsByClassName`

* @param {String} selClass - The selector's class
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {HTMLCollection} - The selected elements
* @returns {HTMLCollectionOf<Element>} - The selected elements
*/
export function byClass(selClass: string, parent?: Element | undefined): HTMLCollection;
export function byClass(selClass: string, parent?: Element | Document | HTMLElement | undefined): HTMLCollectionOf<Element>;
/**

@@ -38,5 +38,5 @@ * Shorthand for `document.getElementById`

*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElement|null} - The selected element
*/
export function byId(id: string): Element | null;
export function byId(id: string): Element | HTMLElement | null;
/**

@@ -46,16 +46,16 @@ * Foreach polyfill for NodeList and HTMLCollection

*
* @param {Array|NodeList|HTMLCollection} els - A list of elements
* @param {Array<any>|NodeList|HTMLCollection} els - A list of elements
* @param {foreachCB} fn - Callback containing ( value, index ) as arguments
* @param {Scope} [scope] - Scope
* @param {Function} [scope] - Scope
*/
export function forEachHTML(els: any[] | NodeList | HTMLCollection, fn: foreachCB, scope?: any): void;
export function forEachHTML(els: Array<any> | NodeList | HTMLCollection, fn: foreachCB, scope?: Function | undefined): void;
/**
* Shorthand for `element.getAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve
*
* @returns {String} - The attribute's value
* @returns {String|null} - The attribute's value
*/
export function getAttr(el: Element, attr: string): string;
export function getAttr(el: Element | HTMLElement, attr: string): string | null;
/**

@@ -65,29 +65,29 @@ * Similar to jQuery `$( el ).index()`

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
*
* @returns {Number} - The element's index
*/
export function getElementIndex(el: Element): number;
export function getElementIndex(el: Element | HTMLElement): number;
/**
* Gets an element left position
*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*
* @returns {Number} Element's left position
*/
export function getLeftPos(el: Element, topEl?: Element | undefined): number;
export function getLeftPos(el: Element | HTMLElement, topEl?: Element | HTMLElement | undefined): number;
/**
* Gets an element top position
*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*
* @returns {Number} Element's top position
*/
export function getTopPos(el: Element, topEl?: Element | undefined): number;
export function getTopPos(el: Element | HTMLElement, topEl?: Element | HTMLElement | undefined): number;
/**
* Shorthand for `element.hasAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to check the existance of

@@ -97,3 +97,3 @@ *

*/
export function hasAttr(el: Element, attr: string): boolean;
export function hasAttr(el: Element | HTMLElement, attr: string): boolean;
/**

@@ -104,3 +104,3 @@ * Checks if an element has a class or not.

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to check the presence of

@@ -110,3 +110,3 @@ *

*/
export function hasClass(el: Element | HTMLCollection | NodeList, ...classes: string[]): boolean;
export function hasClass(el: Element | HTMLElement | HTMLCollection | NodeList, ...classes: string[]): boolean;
/**

@@ -116,3 +116,3 @@ * Foreach callback

* @callback foreachCB
* @param {Element} value - The element
* @param {Element|HTMLElement} value - The element
* @param {Number} [index] - The index of the element

@@ -131,47 +131,47 @@ */

* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElementTagNameMap|SVGElementTagNameMap|null} - The selected element
*/
export function query(selector: string, parent?: Element | undefined): Element | null;
export function query(selector: string, parent?: Element | Document | HTMLElement | undefined): Element | HTMLElementTagNameMap | SVGElementTagNameMap | null;
/**
* Shorthand per `document.querySelectorAll`
* Shorthand for `document.querySelectorAll`
*
* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {NodeList} - The selected element
*/
export function queryAll(selector: string, parent?: Element | undefined): NodeList;
export function queryAll(selector: string, parent?: Element | Document | HTMLElement | undefined): NodeList;
/**
* Shorthand for `element.removeAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to remove
*/
export function remAttr(el: Element, attr: string): void;
export function remAttr(el: Element | HTMLElement, attr: string): void;
/**
* Shorthand for `element.classList.remove`, works with multiple nodes
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to remove
*/
export function removeClass(el: Element | HTMLCollection | NodeList, ...classes: string[]): void;
export function removeClass(el: Element | HTMLElement | HTMLCollection | NodeList, ...classes: string[]): void;
/**
* Shorthand for `element.removeEventListener`
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options
*/
export function removeEvent(el: Element | HTMLCollection | NodeList, ev: string, fn: Function, opts?: Object | undefined): void;
export function removeEvent(el: Element | HTMLElement | Window | Document | MediaQueryList, ev: string, fn: EventListenerOrEventListenerObject, opts?: Object | undefined): void;
/**
* Shorthand for `element.setAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve
* @param {String} val - The value to set to the attribute
*/
export function setAttr(el: Element, attr: string, val: string): void;
export function setAttr(el: Element | HTMLElement, attr: string, val: string): void;
}

@@ -0,1 +1,3 @@

// @ts-check
/**

@@ -6,3 +8,3 @@ * Shorthand for `document.getElementById`

*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElement|null} - The selected element
*/

@@ -16,5 +18,5 @@ function byId(id) {

* @param {String} selClass - The selector's class
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {HTMLCollection} - The selected elements
* @returns {HTMLCollectionOf<Element>} - The selected elements
*/

@@ -29,5 +31,5 @@

* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElementTagNameMap|SVGElementTagNameMap|null} - The selected element
*/

@@ -39,6 +41,6 @@

/**
* Shorthand per `document.querySelectorAll`
* Shorthand for `document.querySelectorAll`
*
* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*

@@ -52,2 +54,4 @@ * @returns {NodeList} - The selected element

// @ts-check
/**

@@ -57,5 +61,5 @@ * Foreach polyfill for NodeList and HTMLCollection

*
* @param {Array|NodeList|HTMLCollection} els - A list of elements
* @param {Array<any>|NodeList|HTMLCollection} els - A list of elements
* @param {foreachCB} fn - Callback containing ( value, index ) as arguments
* @param {Scope} [scope] - Scope
* @param {Function} [scope] - Scope
*/

@@ -69,3 +73,3 @@ function forEachHTML(els, fn, scope) {

* @callback foreachCB
* @param {Element} value - The element
* @param {Element|HTMLElement} value - The element
* @param {Number} [index] - The index of the element

@@ -84,2 +88,3 @@ */

requestAnimationFrame(() => {
// @ts-ignore
fn.call();

@@ -92,4 +97,4 @@ });

*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*

@@ -105,4 +110,4 @@ * @returns {Number} Element's top position

*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*

@@ -119,3 +124,3 @@ * @returns {Number} Element's left position

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
*

@@ -126,3 +131,3 @@ * @returns {Number} - The element's index

function getElementIndex(el) {
let index = 0;
let index = 0; // @ts-ignore

@@ -134,6 +139,7 @@ while (el = el.previousElementSibling) index++;

// @ts-check
/**
* Shorthand for `element.classList.add`, works with multiple nodes
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to add

@@ -143,3 +149,8 @@ */

function addClass(el, ...classes) {
if (el.length === undefined) addClassEl(el, ...classes);else {
// @ts-ignore
if (el.length === undefined) {
// @ts-ignore
addClassEl(el, ...classes);
} else {
// @ts-ignore
forEachHTML(el, currEl => {

@@ -152,6 +163,7 @@ addClassEl(currEl, ...classes);

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} remClass - Classes to add
*/
function addClassEl(elem, ...remClass) {

@@ -166,3 +178,3 @@ remClass.forEach(singleClass => {

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to remove

@@ -172,3 +184,8 @@ */

function removeClass(el, ...classes) {
if (el.length === undefined) removeClassEl(el, ...classes);else {
// @ts-ignore
if (el.length === undefined) {
// @ts-ignore
removeClassEl(el, ...classes);
} else {
// @ts-ignore
forEachHTML(el, currEl => {

@@ -181,6 +198,7 @@ removeClassEl(currEl, ...classes);

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} remClass - Classes to remove
*/
function removeClassEl(elem, ...remClass) {

@@ -197,3 +215,3 @@ remClass.forEach(singleClass => {

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to check the presence of

@@ -205,10 +223,17 @@ *

function hasClass(el, ...classes) {
let hasCls = false;
if (el.length === undefined) hasCls = hasClassEl(el, ...classes);else {
let numClasses = 0;
let hasCls = false; // @ts-ignore
if (el.length === undefined) {
// @ts-ignore
hasCls = hasClassEl(el, ...classes);
} else {
let numClasses = 0; // @ts-ignore
forEachHTML(el, currEl => {
if (hasClassEl(currEl, ...classes)) numClasses++;
});
}); // @ts-ignore
hasCls = numClasses === el.length;
}
return hasCls;

@@ -218,3 +243,3 @@ /**

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} hasClasses - Classes to check the presence of

@@ -234,8 +259,10 @@ *

// @ts-check
/**
* Shorthand for `element.addEventListener`
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options

@@ -249,5 +276,5 @@ */

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options

@@ -260,9 +287,11 @@ */

// @ts-check
/**
* Shorthand for `element.getAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve
*
* @returns {String} - The attribute's value
* @returns {String|null} - The attribute's value
*/

@@ -275,3 +304,3 @@ function getAttr(el, attr) {

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve

@@ -287,3 +316,3 @@ * @param {String} val - The value to set to the attribute

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to remove

@@ -298,3 +327,3 @@ */

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to check the existance of

@@ -301,0 +330,0 @@ *

{
"name": "matt-utils",
"version": "1.4.3",
"version": "1.4.6",
"description": "Some simple shothands for some js functions and methods",
"main": "./dist/matt-utils.js",
"exports": "./dist/matt-utils.js",
"type": "module",
"jest": {
"verbose": true,
"testEnvironment": "jsdom"
},
"scripts": {

@@ -32,19 +37,23 @@ "rl": "rollup -cw",

"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/eslint-parser": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"browserslist": "^4.16.3",
"core-js": "^3.9.1",
"eslint": "^7.21.0",
"glob": "^7.1.6",
"jest": "^26.6.3",
"jsdoc-to-markdown": "^7.0.0",
"rollup": "^2.40.0",
"rollup-plugin-eslint": "^7.0.0",
"@babel/core": "^7.17.9",
"@babel/eslint-parser": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-eslint": "^8.0.2",
"@rollup/plugin-node-resolve": "^13.2.1",
"@types/jest": "^27.4.1",
"browserslist": "^4.20.3",
"core-js": "^3.22.2",
"eslint": "^8.14.0",
"glob": "^8.0.1",
"jest": "^28.0.2",
"jsdoc-to-markdown": "^7.1.1",
"rollup": "^2.70.2",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.2.3"
"typescript": "^4.6.3"
},
"dependencies": {
"jest-environment-jsdom": "^28.0.2"
}
}

@@ -0,8 +1,9 @@

// @ts-check
/**
* Shorthand for `element.getAttribute`
*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve
*
* @returns {String} - The attribute's value
* @returns {String|null} - The attribute's value
*/

@@ -16,3 +17,3 @@ export function getAttr( el, attr ) {

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to retrieve

@@ -28,3 +29,3 @@ * @param {String} val - The value to set to the attribute

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to remove

@@ -39,3 +40,3 @@ */

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
* @param {String} attr - The attribute to check the existance of

@@ -42,0 +43,0 @@ *

@@ -0,1 +1,2 @@

// @ts-check
import { byId, query, getAttr, setAttr, remAttr, hasAttr } from '../../dist/matt-utils.min';

@@ -2,0 +3,0 @@

@@ -0,1 +1,2 @@

// @ts-check
import { forEachHTML } from '../misc/misc';

@@ -6,3 +7,3 @@

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to add

@@ -12,5 +13,8 @@ */

if ( el.length === undefined )
// @ts-ignore
if ( el.length === undefined ) {
// @ts-ignore
addClassEl( el, ...classes );
else {
} else {
// @ts-ignore
forEachHTML( el, ( currEl ) => {

@@ -24,3 +28,3 @@ addClassEl( currEl, ...classes );

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} remClass - Classes to add

@@ -38,3 +42,3 @@ */

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to remove

@@ -44,5 +48,8 @@ */

if ( el.length === undefined )
// @ts-ignore
if ( el.length === undefined ) {
// @ts-ignore
removeClassEl( el, ...classes );
else {
} else {
// @ts-ignore
forEachHTML( el, ( currEl ) => {

@@ -56,3 +63,3 @@ removeClassEl( currEl, ...classes );

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} remClass - Classes to remove

@@ -74,3 +81,3 @@ */

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|HTMLCollection|NodeList} el - A list of elements
* @param {...String} classes - Classes to check the presence of

@@ -84,8 +91,11 @@ *

if ( el.length === undefined )
// @ts-ignore
if ( el.length === undefined ) {
// @ts-ignore
hasCls = hasClassEl( el, ...classes );
else {
} else {
let numClasses = 0;
// @ts-ignore
forEachHTML( el, ( currEl ) => {

@@ -96,2 +106,3 @@ if ( hasClassEl( currEl, ...classes ) )

// @ts-ignore
hasCls = numClasses === el.length;

@@ -106,3 +117,3 @@

*
* @param {Element} elem - An HTML element
* @param {Element|HTMLElement} elem - An HTML element
* @param {...String} hasClasses - Classes to check the presence of

@@ -109,0 +120,0 @@ *

@@ -0,1 +1,2 @@

// @ts-check
import { byId, byClass, query, queryAll, addClass, removeClass, hasClass } from '../../dist/matt-utils.min';

@@ -2,0 +3,0 @@

@@ -0,7 +1,9 @@

// @ts-check
/**
* Shorthand for `element.addEventListener`
*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options

@@ -18,5 +20,5 @@ */

*
* @param {Element|HTMLCollection|NodeList} el - A list of elements
* @param {Element|HTMLElement|Window|Document|MediaQueryList} el - A list of elements
* @param {String} ev - Event's name
* @param {Function} fn - Event's function
* @param {EventListenerOrEventListenerObject} fn - Event's function
* @param {Object} [opts] - Optional event options

@@ -23,0 +25,0 @@ */

@@ -0,1 +1,2 @@

// @ts-check
import { byId, addEvent, removeEvent } from '../../dist/matt-utils.min';

@@ -2,0 +3,0 @@

@@ -0,1 +1,3 @@

// @ts-check
/**

@@ -5,5 +7,5 @@ * Foreach polyfill for NodeList and HTMLCollection

*
* @param {Array|NodeList|HTMLCollection} els - A list of elements
* @param {Array<any>|NodeList|HTMLCollection} els - A list of elements
* @param {foreachCB} fn - Callback containing ( value, index ) as arguments
* @param {Scope} [scope] - Scope
* @param {Function} [scope] - Scope
*/

@@ -19,3 +21,3 @@ export function forEachHTML( els, fn, scope ) {

* @callback foreachCB
* @param {Element} value - The element
* @param {Element|HTMLElement} value - The element
* @param {Number} [index] - The index of the element

@@ -34,2 +36,3 @@ */

requestAnimationFrame( () => {
// @ts-ignore
fn.call();

@@ -44,4 +47,4 @@ });

*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*

@@ -57,4 +60,4 @@ * @returns {Number} Element's top position

*
* @param {Element} el - An HTML element
* @param {Element} [topEl=document.body] - Wrapping element
* @param {Element|HTMLElement} el - An HTML element
* @param {Element|HTMLElement} [topEl=document.body] - Wrapping element
*

@@ -72,3 +75,3 @@ * @returns {Number} Element's left position

*
* @param {Element} el - An HTML element
* @param {Element|HTMLElement} el - An HTML element
*

@@ -81,2 +84,3 @@ * @returns {Number} - The element's index

// @ts-ignore
while ( ( el = el.previousElementSibling ) )

@@ -83,0 +87,0 @@ index++;

@@ -0,1 +1,2 @@

// @ts-check
import { byId, getElementIndex } from '../../dist/matt-utils.min';

@@ -2,0 +3,0 @@

@@ -0,1 +1,2 @@

// @ts-check
/**

@@ -6,3 +7,3 @@ * Shorthand for `document.getElementById`

*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElement|null} - The selected element
*/

@@ -17,5 +18,5 @@ export function byId( id ) {

* @param {String} selClass - The selector's class
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {HTMLCollection} - The selected elements
* @returns {HTMLCollectionOf<Element>} - The selected elements
*/

@@ -31,5 +32,5 @@ export function byClass( selClass, parent = document ) {

* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*
* @returns {Element|null} - The selected element
* @returns {Element|HTMLElementTagNameMap|SVGElementTagNameMap|null} - The selected element
*/

@@ -42,6 +43,6 @@ export function query( selector, parent = document ) {

/**
* Shorthand per `document.querySelectorAll`
* Shorthand for `document.querySelectorAll`
*
* @param {String} selector - Selector
* @param {Element} [parent=document] - Parent element
* @param {Element|HTMLElement|Document} [parent=document] - Parent element
*

@@ -48,0 +49,0 @@ * @returns {NodeList} - The selected element

@@ -0,1 +1,2 @@

// @ts-check
import { byId, byClass, query, queryAll } from '../../dist/matt-utils.min';

@@ -2,0 +3,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc