1.0.0 • Published 8 years ago

couldbe v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

couldbe Build Status Coverage Status

A Maybe-style monoid for JavaScript.

Usage

Given some arbitrary data, e.g.

const data = {
  id: 1
  content: {
    title: 'hello'
  }
}

Instead of ...

if (data.content)
  data.content.body || 'world'

... do the following:

import couldbe from 'couldbe'

couldbe(data)('content')('title')         === 'hello'
couldbe(data)('content')('body', 'world') === 'world'