JSFiddle - React, Tailwind, and code Playground

by Alexander

JavaScript

console.clear();

let a = {
	foo: 123,
  bar: 123
};

const Box = x =>
({
	map: f => Box(f(x)),
  fold: f => f(x),
  inspect() {
  	console.log(`Box(${ /^\[object/.test(''+x) ? JSON.stringify(x) : x }):\n\t`, x)
    return this
  }
})

a = Box(a)
	.map(o => (o.foo = 456, o) )
  .inspect()
  .map(o => (o.bar = 'abc', o) )
  .fold(o => o)

console.log(a);