You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
436 B

4 years ago
  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;