Skip to content

Instantly share code, notes, and snippets.

View brenolf's full-sized avatar
🦆

Breno Freitas brenolf

🦆
View GitHub Profile
@dtipson
dtipson / IO plus Array & Promise helpers.js
Last active October 1, 2019 07:56
Bare bones FP type utility lib so we can play around with functions that capture the composition of DOM read/writes, but in a pure way
// Let's make it possible to create pure functions even when we're
// dealing with impure operations that would have side effects!
// First we'll need a "Type" that can contain a (sometimes impure) function
function IO(fn) {
if (!(this instanceof IO)) {//make it simpler for end users to create a type without "new"
return new IO(fn);
}
this.runIO = fn;//IO now provides an extra control layer that allows the composition of unexecuted effects