Nitrogen Poisonous Monoxide
Miss any of our Open RFC calls?Watch the recordings here! »

@alcadica/maybe

1.0.2 • Public • Published

@alcadica/maybe

Coverage Maintainability

Implements the maybe monad

Install

npm install --save @alcadica/maybe

Examples

import maybe from '@alcadica/maybe';
 
const testObject = {
  a: {
    b: {
      c: {
        d: 100,
        e: 200,
      },
    },
  },
  a1: [
    {
      b1: [
        {
          c1: 100
        }
      ]
    }
  ]
}
 
const d = maybe(testObject, 'a.b.c.d'); // 100
const e = maybe(testObject, 'a.b.c.e'); // 200
const f = maybe(testObject, 'a.b.c.f'); // f does not exists, will return undefined
const f2 = maybe(testObject, 'a.b.c.f', 300); // f does not exists, will return 300 as a fallback
 
// you can also try to get array values providing an index
const c1 = maybe(testObject, 'a1.0.b1.0.c1'); // will return 100

Licence

MIT

Install

npm i @alcadica/maybe

DownloadsWeekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

5.21 kB

Total Files

5

Last publish

Collaborators

  • avatar
  • avatar