Access properties on a JS object reliably, throwing an error if the property does not exist. Does not support symbol keys (silently returns undefined). Notice: Does not keep bound-this properties. Throws if the
npm install safe-property-accessvar access = require("safe-property-access")
console.log(access({ a: 1 }, "a")) // 1
console.log(access({ foo: "bar" }, "nonExistentProperty")) // Error: expects something with nonExistentProperty property
console.log(access({ undefinedValue: undefined }, "undefinedValue")) // Error: expects something with undefinedValue property
// length has its own special one
console.log(access.length("hi")) // 2
console.log(access.length(access)(access) === access.length) // true