Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ function rest(list) {
* @returns {boolean}
* @example isEmpty([1, 2, 3]); // => false
* @example isEmpty([]); // => true

* @example isEmpty(""); // => true
*/
function isEmpty(list) {
if (typeof list == 'object') {
return list.length === 0;
}
if (typeof list == 'string') {
return list.length === 0;
}
return false;
}

Expand All @@ -59,6 +62,19 @@ function isList(list) {
return typeof list === 'object' && typeof list.length == 'number' && list.length >= 0;
}

/**
* Retorna verdadero si el objeto de entrada es una cadena de texto
* @param {String} str
* @returns {boolean}
* @example isString(""); // => true
* @example isString([1, 2]); // => false
* @example isString(1); // => false
* @example isString("Hola"); // => true
*/
function isString(str) {
return typeof str === 'string' && typeof str.length == 'number' && str.length >= 0;
}

/**
* Retorna la longitud de un arreglo
* @param {Array} list
Expand Down