Conjunto de Utilidades
Grupo de Funciones Utiles para nuestros proyectos
- Source
Namespaces
Members
(static, constant) exports.camelCase :function
CamelCase
- function
- Source
(static, constant) exports.defineProperty :function
Alias Object.defineProperty
- function
- Source
(static, constant) exports.gOPD :function
Alias Object.getOwnPropertyDescriptor
- function
- Source
(static, constant) exports.strValue :function
Alias String.prototype.valueOf
- function
- Source
(static, constant) exports.toStr :function
Alias Object.prototype.toString
- function
- Source
(static, constant) exports.tryStringObject
Valida String u Object
- Source
Methods
(static) cleanPreCode(textContent) → {String}
Limpia un texto pre-codificado
| Name | Type | Description |
|---|---|---|
textContent | String | Texto |
- Source
- Type:
- String
(static) createScript(script) → {Element}
Analiza y crea un nuevo elemento script que añada al body
Util para el uso de Ajax, y cargas de html en linea
| Name | Type | Description |
|---|---|---|
script | String | |
- Source
El nuevo Script
- Type:
- Element
(static) createURI(u) → {String}
Crea una uri a partir de un String
| Name | Type | Description |
|---|---|---|
u | String | Dirección o path a convertir |
- Source
URI bien formateada
- Type:
- String
_$.createURI('mifile.php')
// return --> https://domain.ext/path/mifile.php(static) each(arr, callback, thisArg)
ForEach Personalizado.
Extiende la funcionalidad del forEach por defecto de los Array para todo tipo de elementos.
Para saber más visite forEach en Developer Mozilla
| Name | Type | Description |
|---|---|---|
arr | Object | | El Objecto a iterar |
callback | function | Función a ejecutar |
thisArg | Object | | Valor de la constante this |
- Source
(static) empty(arg) → {Boolean}
Verifica si la variable dada esta vaciá
| Name | Type | Description |
|---|---|---|
arg | * | Variable, Objecto, matriz etc.. a verificar |
- Source
Verdadero si esta vació
- Type:
- Boolean
let a
empty(a) // true
empty(0) // true
empty(0.0) // true
empty(false) // true
empty([]) // true
empty({}) // true
empty("") // true
empty() // true
empty(1) // false(static) extend(…Argumentos) → {String|Object|Array}
Extiende un objeto o matriz y combinar sus elementos
| Name | Type | Attributes | Description |
|---|---|---|---|
Argumentos | * | <repeatable> | Lista de Objetos a iterar |
- Source
retorna el elemento, o la unión de ellos
- Type:
- String |
Object | Array
(static) formatBytes(bytes, decimals) → {String}
Transforma un Byte en su unidad correspondiente
| Name | Type | Description |
|---|---|---|
bytes | Number | Bytes a dar formato |
decimals | Number | Cantidad de decimales a mostrar |
- Source
- Type:
- String
(static) getStyleComputed(el, prop, pseudoElt) → {Array}
Obtiene los estilos computados del elemento
| Name | Type | Description |
|---|---|---|
el | Element | El Elemento |
prop | String | La Propiedad |
pseudoElt | String | PseudoElt |
- Source
- Type:
- Array
(static) hasProp(obj, prop) → {Boolean}
Busca y valida la propiedad del objeto dato
| Name | Type | Description |
|---|---|---|
obj | Object | objeto a verificar |
prop | String | propiedad a buscar |
- Source
verdadero si la propiedad existe dentro del objeto
- Type:
- Boolean
(static) htmlEntities(str) → {String}
Genera una cadena HTML codificada para mostrar en pre o navegador
| Name | Type | Description |
|---|---|---|
str | String | Cadena de código Html |
- Source
- Type:
- String
<div>
<pre></pre>
<script>
_$("pre").html(_$.htmlEntities("<section><h2>Hola Mundo</h2></section>"))
</script>
</div>(static) isArray() → {Boolean}
Verifica si es una Array
- Source
- Type:
- Boolean
(static) isArrayish(obj) → {Boolean}
Verifica si es una Matriz
| Name | Type | Description |
|---|---|---|
obj | * |
- Source
Verdadero si es un array
- Type:
- Boolean
(static) isElement(el) → {Boolean}
Verifica si es un elemento
| Name | Type | Description |
|---|---|---|
el | * |
- Source
Verdadero si el es un Elemento del DOM
- Type:
- Boolean
(static) isFascinoElement(el) → {Boolean}
Verifica si es un Elemento Fascino
| Name | Type | Description |
|---|---|---|
el | * |
- Source
Verdadero si es un elemento de Fascino o _$
- Type:
- Boolean
(static) isFunction(fn) → {Boolean}
Verifica si es una función
| Name | Type | Description |
|---|---|---|
fn | * |
- Source
verdadero si es una función
- Type:
- Boolean
(static) isHiden(el) → {Boolean}
Verifica si el elemento esta oculto
| Name | Type | Description |
|---|---|---|
el | String | |
- Source
Verdadero si esta oculto
- Type:
- Boolean
(static) isNumber(num) → {Boolean}
Verifica si es un número
| Name | Type | Description |
|---|---|---|
num | * |
- Source
verdadero si es un tipo numérico
- Type:
- Boolean
(static) isObject(obj) → {Boolean}
Verifica si es un objecto
| Name | Type | Description |
|---|---|---|
obj | * |
- Source
verdadero si es un objecto
- Type:
- Boolean
(static) isSelector(selector) → {Boolean}
Verifica si es un selector valido
| Name | Type | Description |
|---|---|---|
selector | String |
- Source
Verdadero si es un selector
- Type:
- Boolean
(static) isString(value) → {Boolean}
Verifica si es un texto valido
| Name | Type | Description |
|---|---|---|
value | * |
- Source
verdadero si es un string
- Type:
- Boolean
(static) isURL(u) → {Boolean}
Valida una URL
| Name | Type | Description |
|---|---|---|
u | String | | URI a validar |
- Source
- Type:
- Boolean
(static) isVisible(el) → {Boolean}
Verifica si el elemento es visible en el DOM
| Name | Type | Description |
|---|---|---|
el | String | |
- Source
Verdadero si es visible
- Type:
- Boolean
(static) jsonToFormdata(obj) → {FromData}
Convierte un Objecto JSON a u objecto del tipo FromData
| Name | Type | Description |
|---|---|---|
obj | Object | El Objecto |
- Source
- Type:
- FromData
(static) merge(n1, n2) → {Array}
Combinar 2 array
| Name | Type | Description |
|---|---|---|
n1 | Array | Matriz n1 |
n2 | Array | Matriz n2 |
- Source
El array resultante
- Type:
- Array
(static) normalizeData(data) → {Object}
Convierte los datos tipo texto JSON pasados por atributos a un objecto valido
| Name | Type | Description |
|---|---|---|
data | String |
- Source
El objeto JSON
- Type:
- Object
(static) normalizeElements(s) → {Object|Element|Array|undefined}
Valida y obtiene un elemento dado
| Name | Type | Description |
|---|---|---|
s | String | |
- Source
El elemento en su expresión para su uso
- Type:
- Object |
Element | Array | undefined
(static) normName(name) → {String|void}
Regula y normaliza el nombre de un atributo, función, o variable para su uso en Javascript
| Name | Type | Description |
|---|---|---|
name | String | variable |
- Source
el nombre normalizado o indefinido
- Type:
- String |
void
(static) not(arg) → {Boolean}
Verifica si la variable dada no es nula o indefinida
| Name | Type | Description |
|---|---|---|
arg | * | Variable |
- Source
verdadero si esta nula o indefinida
- Type:
- Boolean
(static) parseHTML(data) → {Element|Array}
Esta función recibe una etiqueta e intenta crear un Object HTMLElement de la misma
| Name | Type | Description |
|---|---|---|
data | String | el texto HTML |
- Source
El nuevo objeto o una matriz
- Type:
- Element |
Array
(static) random(min, max) → {Number}
Genera un numero aleatorio entre rangos
| Name | Type | Description |
|---|---|---|
min | Number | | Número minino |
max | Number | | Número máximo |
- Source
Resultado aleatorio
- Type:
- Number
(static) randomMap(arr) → {Number|*}
Obtiene un valor Aleatorio de una Matriz o un Objeto
| Name | Type | Description |
|---|---|---|
arr | Object | | Matriz u Objecto |
- Source
Valor de la Matriz u Objecto o -1 si no tiene éxito
- Type:
- Number |
*
(static) script(el) → {void}
Normaliza y busca los elementos Script
| Name | Type | Description |
|---|---|---|
el | Element | El elemento script o padre del Script |
- Source
- Type:
- void
(static) SetOptinsOfData(el, defaults) → {Object}
Establece opciones por defecto a los Simple plugins
| Name | Type | Description |
|---|---|---|
el | Element | | Elemento |
defaults | Object | Opciones por defecto |
- Source
Nuevas Opciones
- Type:
- Object
(static) strToArr(str, separator) → {Array}
Transforma una cadena de texto en una matriz
| Name | Type | Description |
|---|---|---|
str | String | La cadena |
separator | String | El separador |
- Source
- Type:
- Array
(static) template(html, options, conf) → {String}
Mini Motor de plantillas javascript
| Name | Type | Description |
|---|---|---|
html | String | Código HTML de la plantilla |
options | Object | Opciones de plantilla para reemplazar |
conf | Object | Configuraciones del motor |
- Source
- Type:
- String
Uso
var html = `
<div class='alert alert<%this.type%>' role="alert">
<%this.content%>
</div>
`;
var options = {
type: 'info',
content:'This is Alerts'
}
document.write(_$.template(html,options))(static) toString(arg) → {Boolean|String}
Extensión de [object|function|array|string].toString([native])
| Name | Type | Description |
|---|---|---|
arg | string | tipo que contiene la función toString |
- Source
El resultado del toString o falso
- Type:
- Boolean |
String
(static) uniqueId(prefix) → {String}
Genera un Identificador único basado en la fecha y hora actual
| Name | Type | Description |
|---|---|---|
prefix | String | Prefijo del identificador |
- Source
Identificador
- Type:
- String
(static) url(urlBase, params) → {URL}
Construye una URL valida para la API fetch o XMLHttpRequest
| Name | Type | Description |
|---|---|---|
urlBase | String | URL |
params | Object | Conjunto de parametros de URLSearchParams |
- Source
API URL
- Type:
- URL