safechainjs
A simple, light and safe way to access object's property in any level. It also assign back the fallback value if there is no given properties.
- First parameter is object to look into.
- Multiple parameters as string as property of object.
- Last parameter is fallback value to be returned, if request value is not present.
Installation
npm install safechainjs --save
Usage
Javascript
const safechain = ;const obj = name: firstName: "Albert" lastName: "Einstein" dob: "1897/03/14" wife: 'Maric' 'Elsa';const propertyWife = 'wife';const fname = ; // Albertconst address = ; // 0const wives = ; // ['Maric', 'Elsa']
Test
npm run test