DEV Community

Discussion on: Functor's flavor in JS

Collapse
 
olavoparno profile image
Olavo Parno • Edited

HAHAHA awesome dude

const secureType = value => ({
value,
map(fn) {
console.log(this.value)
return secureType(fn(this.value))
}
})

// using
const { value } = secureType('who\'s bad?')
.map(text => text.toUpperCase())
.map(text => ${text} 👹)
.map(text => ${text} 👹)
.map(text => ${text} 👹)
.map(text => ${text} 👹)

Test