_deepGet.js 292 B

1234567891011
  1. // Internal function to obtain a nested property in `obj` along `path`.
  2. function deepGet(obj, path) {
  3. var length = path.length;
  4. for (var i = 0; i < length; i++) {
  5. if (obj == null) return void 0;
  6. obj = obj[path[i]];
  7. }
  8. return length ? obj : void 0;
  9. }
  10. module.exports = deepGet;