Skip to content

devMYC/sfobj

Folders and files

NameName
Last commit message
Last commit date
Jul 15, 2019
Jul 15, 2019
Jul 15, 2019
Jul 15, 2019
Jul 15, 2019
Jul 24, 2019
Jul 15, 2019
Jul 15, 2019
Jul 24, 2019
Jul 24, 2019
Jul 15, 2019
Jul 15, 2019
Jun 28, 2020

Repository files navigation

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] || ''