Skip to content

Latest commit

 

History

History
16 lines (10 loc) · 325 Bytes

README.md

File metadata and controls

16 lines (10 loc) · 325 Bytes

Safely access properties of any sort of object!

Requirements

  • Node 6.0 or later

Usage

import safe, { either } from 'safely'

const dangerousObject = { data: [{ values: [] }]}

safe(dangerousObject).data[0].values[0].value // returns {}
either(safe(dangerousObject).data[0].values[0].value, 42) // returns 42