Skip to content

Instantly share code, notes, and snippets.

View cesarfrick's full-sized avatar

Cesar Frick cesarfrick

View GitHub Profile
@cesarfrick
cesarfrick / compose.js
Last active July 31, 2018 01:14
Different compose utility methods
// Simple composing (ES6)
// Belongs to Stefan A. Maric
const compose = (...fns) => x => fns.reduceRight((v, f) => f(v), x);
/*****************************/
// Recursive composing
// Belongs to Stefan A. Maric
const compose = (head, ...rest) => x => head ? head(compose(...rest)(x)) : x;
@cesarfrick
cesarfrick / template-renderer.js
Last active January 31, 2018 15:53
Simple template rendering (ES6)
/**
* @method fromTemplate
* @description
* Converts an HTML element string to a DOM object
* @param {String} templateString String representation of a DOM element (e.g. '<div>content</div>')
* @returns {Node}
*/
export const fromTemplate = templateString => {
var el = document.createElement('div');
el.innerHTML = templateString;