Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Latest commit

 

History

History
384 lines (271 loc) · 11.8 KB

DOCUMENTATION.md

File metadata and controls

384 lines (271 loc) · 11.8 KB

Modules

aelCurriedAEL

Listen to several events on an element or a group of elements.

atrCurriedATR

Set several attributes of an element or a group of elements.

cksRecord.<string, string>

Get the current document cookies in object form.

cneCurriedCNE

Creates a new element.

cssCurriedCSS

Set several styles of an element or a group of elements.

delArray.<HTMLElement>

Remove an element or a group of elements from the DOM.

domArray.<Document>

Parse string into DOM.

getArray.<HTMLElement>

Alias for querySelectorAll in an array.

mrxCurriedMRX

Takes a string and an object and makes a regex map replace

objObjectType

Creates a clean object.

tshstring

Timestamp string hash generator (up to 8 characters).

urlstring

Parse an object into a simple string in URL format for XHR.

xhrCurriedXHR

Alias for new XMLHttpRequest, with GET method by default.

Typedefs

CurriedAELArray.<HTMLElement>
CurriedATRArray.<HTMLElement>
CurriedCNEArray.<HTMLElement>
CurriedCSSArray.<HTMLElement>
CurriedMRXstring
CurriedXHRXMLHttpRequest

ael ⇒ CurriedAEL

Listen to several events on an element or a group of elements.

Param Type Description
V Record.<string, EventListener> List of events and callbacks in Object format.

Example

// <a id="id">Link</a>
ael({
	click: event => {
		event.preventDefault();
		console.log("#id element clicked");
	},
})(get("#id"));

atr ⇒ CurriedATR

Set several attributes of an element or a group of elements.

Param Type Description
A Record.<string, string> List of attributes in Object format.

Example

// <a id="id">Link</a>
atr({
	class: "a-class",
})(get("#id"));
// <a id="id" class="a-class">Link</a>

cks ⇒ Record.<string, string>

Get the current document cookies in object form.

Returns: Record.<string, string> - The document cookies object.

Param Type Description
[C] string Cookie string (default to document.cookie).

Example

cks(); // If document.cookie is "a=1; b=2", returns { a: 1, b: 2 }
cks(); // If document.cookie is empty, returns {}

cne ⇒ CurriedCNE

Creates a new element.

Param Type Description
t string Element tag.

Example

cne("div")(); // Returns <div></div>
cne("div")({
	width: "100",
	height: "100",
	style: {
		backgroundColor: "#000",
	},
}); // Returns <div width="100" height="100" style="background-color:#000"></div>

css ⇒ CurriedCSS

Set several styles of an element or a group of elements.

Param Type Description
S CSSStyleDeclaration List of styles in Object format.

Example

// <a id="id">Link</a>
css({
	fontWeight: 700,
})(get("#id"));
// <a id="id" style="font-weight:700">Link</a>

del ⇒ Array.<HTMLElement>

Remove an element or a group of elements from the DOM.

Returns: Array.<HTMLElement> - Array of DOM Elements removed from DOM.

Param Type Description
E Array.<HTMLElement> Array of DOM Elements to remove from DOM.

Example

// <a id="id">Link</a>
del(get("#id")); // Element gets removed from the DOM and returned

dom ⇒ Array.<Document>

Parse string into DOM.

Returns: Array.<Document> - Parsed DOM.

Param Type Description
s string String to be parsed.

Example

dom("<a>Hello world</a>"); // Returns document object with that link on the body

get ⇒ Array.<HTMLElement>

Alias for querySelectorAll in an array.

Returns: Array.<HTMLElement> - Array of elements.

Param Type Description
q string CSS Query.

Example

// <a id="id">Link</a>
get("#id"); // Above element gets returned

mrx ⇒ CurriedMRX

Takes a string and an object and makes a regex map replace

Param Type Description
m Record.<string, string> Map with format { "target": "replacing string" }.

Example

mrx({ a: 1, b: 2, c: 3 })("abc"); // Returns "123"

obj ⇒ ObjectType

Creates a clean object.

Returns: ObjectType - New clean object.

Param Type Description
o ObjectType Objects to use.

Example

obj({ a: 1, b: 2, c: 3 }).__proto__ === void 0; // true, because is a clean object

tsh ⇒ string

Timestamp string hash generator (up to 8 characters).

Returns: string - A timestamp hash.

Param Type Default Description
[l] number 8 Length of the random string (8 max).

Example

tsh(); // Timestamp hash of 8 characters, like: "km5ztiej".
tsh(4); // Timestamp hash of 4 characters, like: "ytbz".

url ⇒ string

Parse an object into a simple string in URL format for XHR.

Returns: string - URL formated string.

Param Type Description
o ObjectType List of input data for ajax in Object format.

Example

url({ a: 1, b: 2, c: 3 }); // Returns "a=1&b=2&c=3"
url({ a: [1, 2, 3], b: { c: 1, d: 2 } }); // Returns "a[0]=1&a[1]=2&a[2]=3&b[c]=1&b[d]=2"

xhr ⇒ CurriedXHR

Alias for new XMLHttpRequest, with GET method by default.

Returns: CurriedXHR - Curried function that returns the opened XML HTTP Request.

Param Type Description
m string Method (GET/PUT/POST/PATCH/DELETE).

Example

xhr("GET")("/api").send(); // Sends request to /api

CurriedAEL ⇒ Array.<HTMLElement>

Kind: global typedef
Returns: Array.<HTMLElement> - Array of DOM Elements with new attributes.

Param Type Description
E Array.<HTMLElement> Array of DOM Elements with event.

CurriedATR ⇒ Array.<HTMLElement>

Kind: global typedef
Returns: Array.<HTMLElement> - Array of DOM Elements with new attributes.

Param Type Description
E Array.<HTMLElement> Array of DOM Elements with event.

CurriedCNE ⇒ Array.<HTMLElement>

Kind: global typedef
Returns: Array.<HTMLElement> - New element with properties set.

Param Type Description
[P] HTMLElement Element properties.

CurriedCSS ⇒ Array.<HTMLElement>

Kind: global typedef
Returns: Array.<HTMLElement> - Array of DOM Elements with new styles.

Param Type Description
E Array.<HTMLElement> Array of DOM Elements to set styles.

CurriedMRX ⇒ string

Kind: global typedef
Returns: string - String with replaced elements from map.

Param Type Description
s string String.

CurriedXHR ⇒ XMLHttpRequest

Kind: global typedef
Returns: XMLHttpRequest - DOM Element or Array of DOM Elements with new attributes.

Param Type Description
u string URL to make the request to.