jueves, 6 de noviembre de 2014

Immutable.js

Como sabrán Javascript es un lenguaje muy influenciado por lenguajes funcionales. Clausuras, Curryng, etc.

Con Immutable.js tienes la característica de los inmutables en javascript!!

El framework permite generar listas y luego no poder modificarlas. Dando le una mayor seriedad al lenguaje.

Veamos un ejemplo:

var list1 = Immutable.List.of(1, 2);
var list2 = list1.push(3, 4, 5);
var list3 = list2.unshift(0);
var list4 = list1.concat(list2, list3);
assert(list1.size === 2);
assert(list2.size === 5);
assert(list3.size === 6);
assert(list4.size === 13);
assert(list4.get(0) === 1);
Dejo link! https://github.com/facebook/immutable-js




No hay comentarios.:

Publicar un comentario