Skip to content

mfellner/couldbe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

A Maybe-style monoid for JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages