1.0.1 • Published 5 years ago

sfobj v1.0.1

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

CircleCI codecov

$ npm install sfobj

Usage

import Safe, { unwrap } from 'sfobj'
// const { Safe, unwrap } = require('sfobj')

const obj = Safe({ hello: 'world' })

console.log(obj.hello[unwrap]) // Output: world
console.log(obj.this.prop[0].does.not().even.exist()[unwrap]) // Output: undefined


// No more null/undefined checks
if (typeof obj.a.b().c[1].d()[unwrap] === 'number') {
  // do something here
}

// Easier to set default value
const name = obj.getUsers().list[0].name[unwrap] || ''