npm install couldbeA Maybe-style monoid for JavaScript.
Given some arbitrary data, e.g.
``javascript`
const data = {
id: 1
content: {
title: 'hello'
}
}
Instead of ...
`javascript`
if (data.content)
data.content.body || 'world'
... do the following:
`javascript
import couldbe from 'couldbe'
couldbe(data)('content')('title') === 'hello'
couldbe(data)('content')('body', 'world') === 'world'
``