Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

try-get

seapunk28MIT1.0.0

Gets a value of an object, giving provided default if not possible.

readme

try-get

Gets a value of an object, giving provided default if not possible.

import tryGet from 'try-get'

const a = {
  b: {
    c: 4
  }
}

tryGet(a, 'b.c', 'fail') // 4
tryGet(a, 'b.d', 'fail') // fail
tryGet(a, 'b.d') // undefined

related: deep-exists