functional-light
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,1 +1,6 @@ | ||
/** | ||
* Agreaga el elemento value al comienzo de la lista. | ||
* @param {*} value | ||
* @param {Array} list | ||
*/ | ||
function cons(value, list) { | ||
@@ -7,2 +12,6 @@ let tmp = list.slice(0); | ||
/** | ||
* Retorma el primer elemento de la lista | ||
* @param {Array} list | ||
*/ | ||
function first(list) { | ||
@@ -12,2 +21,6 @@ return list.slice(0, 1)[0]; | ||
/** | ||
* Retorna todos los elementos de la lista, excepto el primero | ||
* @param {Array} list | ||
*/ | ||
function rest(list) { | ||
@@ -17,2 +30,6 @@ return list.slice(1); | ||
/** | ||
* La lista de entrada está vacio? | ||
* @param {Array} list | ||
*/ | ||
function isEmpty(list) { | ||
@@ -25,2 +42,6 @@ if (typeof list == 'object') { | ||
/** | ||
* El objeto de entrada es una lista? | ||
* @param {Array} list | ||
*/ | ||
function isList(list) { | ||
@@ -30,2 +51,27 @@ return typeof list === 'object' && typeof list.length == 'number' && list.length >= 0; | ||
module.exports = { cons, first, rest, isEmpty, isList }; | ||
/** | ||
* Retorna la longitud de un arreglo | ||
* @param {Array} list | ||
*/ | ||
function length(list) { | ||
return list.length; | ||
} | ||
/** | ||
* Concatena la list2 al final de la list1. Si list2 no es un arreglo, simplemente agrega | ||
* este elemento al final de list1. | ||
* @param {Array} list1 | ||
* @param {Array | Object} list2 | ||
*/ | ||
function append(list1, list2) { | ||
let tmp = list1.slice(); | ||
if (typeof list2 === 'object' && list2.length >= 0) { | ||
tmp.push(...list2); | ||
return tmp; | ||
} else { | ||
tmp.push(list2); | ||
return tmp; | ||
} | ||
} | ||
module.exports = { cons, first, rest, isEmpty, isList, length, append }; |
{ | ||
"name": "functional-light", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Librería para el curso de programación funcional con JavaScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3624
64