_parent.js 436 B

1234567891011121314151617
  1. var baseGet = require('./_baseGet'),
  2. baseSlice = require('./_baseSlice');
  3. /**
  4. * Gets the parent value at `path` of `object`.
  5. *
  6. * @private
  7. * @param {Object} object The object to query.
  8. * @param {Array} path The path to get the parent value of.
  9. * @returns {*} Returns the parent value.
  10. */
  11. function parent(object, path) {
  12. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  13. }
  14. module.exports = parent;