node-dotpath-strict
Aren't there a million of these already?
I couldn't find one that distinguishes between a property that is unset and one that is set to undefined so I made this. It throws an error when attempting to access a nonexisting property. Supports basic dot notation and numeric brackets.
Example
var dotPath = ;var post = title: "Readme" author: firstName: "Hugh" lastName: "Mungus" ;;//"Hugh"
Installation
npm i dotpath-strict
API Reference
*
⏏
dotPath(object, path, [value]) ⇒ Kind: Exported function
Throws:
ReferenceError
TypeError
Params
- object
Object
- path
string
- [value]
string
- Set property to this value
Example
var obj = a: aa: 1 ab: "1" "2" b: undefined c: null ;;//1;//"2";//undefined;//null;//ReferenceError: d is not defined;//"2";//TypeError: d is not an object;//{ e: 3 };//3
License
MPL 2.0