- ael ⇒
CurriedAEL
Listen to several events on an element or a group of elements.
- atr ⇒
CurriedATR
Set several attributes of an element or a group of elements.
- cks ⇒
Record.<string, string>
Get the current document cookies in object form.
- cne ⇒
CurriedCNE
Creates a new element.
- css ⇒
CurriedCSS
Set several styles of an element or a group of elements.
- del ⇒
Array.<HTMLElement>
Remove an element or a group of elements from the DOM.
- dom ⇒
Array.<Document>
Parse string into DOM.
- get ⇒
Array.<HTMLElement>
Alias for querySelectorAll in an array.
- mrx ⇒
CurriedMRX
Takes a string and an object and makes a regex map replace
- obj ⇒
ObjectType
Creates a clean object.
- tsh ⇒
string
Timestamp string hash generator (up to 8 characters).
- url ⇒
string
Parse an object into a simple string in URL format for XHR.
- xhr ⇒
CurriedXHR
Alias for new XMLHttpRequest, with GET method by default.
- CurriedAEL ⇒
Array.<HTMLElement>
- CurriedATR ⇒
Array.<HTMLElement>
- CurriedCNE ⇒
Array.<HTMLElement>
- CurriedCSS ⇒
Array.<HTMLElement>
- CurriedMRX ⇒
string
- CurriedXHR ⇒
XMLHttpRequest
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>
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>
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
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
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"
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
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".
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
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. |
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. |
Kind: global typedef
Returns: Array.<HTMLElement>
- New element with
properties set.
Param | Type | Description |
---|---|---|
[P] | HTMLElement |
Element properties. |
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. |
Kind: global typedef
Returns: string
- String with replaced elements from map.
Param | Type | Description |
---|---|---|
s | string |
String. |
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. |