1.0.0 • Published 6 months ago

fp-elements v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

FP style Element creation

Create elements

Use Element.of(type) to create your elements:

const imgElement = Element.of("img");

Each element is lazy evaluated, it does not create the real dom element until you call fold()

const imgElement = Element.of("img");
const element = imgElement.fold();

You can chain operations, each chain will produce a new element without any mutations

const imgElement = Element('img');
const elementWithId = imgElement.id("one");
const elementWithClass = imgElement.class("class");
const elementWithClassAndId = elementWithId.class("classId", "yes", "ok");

console.log(imgElement.fold());
console.log(elementWithId.fold());
console.log(elementWithClass.fold());
console.log(elementWithClassAndId.fold());