JSFiddle - React, Tailwind, and code Playground

by mcsf

HTML

<script src="https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)"></script>

CSS

body { font-family: monospace }

JavaScript

Object.assign(window, _)
print = x => document.documentElement.innerHTML += (
  '<p>' + JSON.stringify(x) + '</p>')

runMaybe = (input, fn) => getOr(null, 0, fn([ input ]))

normalize1 = (input) =>
	runMaybe(input, flow([
  	compact, // simple truthiness check, or
    filter(isString), // actual type check
    map(s => s.replace('o', 'ooo')),
    map(toUpper),
    filter(flow(prop('length'), lt(4))),
  ]))
  
print(normalize1(undefined))
print(normalize1(''))
print(normalize1('foo'))
print(normalize1('bar'))
print(normalize1({ s: 'bar' }))