UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

20 lines (19 loc) 712 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const baseGet_1 = __importDefault(require("./baseGet")); const slice_1 = __importDefault(require("../slice")); /** * Gets the parent value at `path` of `object`. * * @private * @param {Object} object The object to query. * @param {Array} path The path to get the parent value of. * @returns {*} Returns the parent value. */ function parent(object, path) { return path.length < 2 ? object : (0, baseGet_1.default)(object, (0, slice_1.default)(path, 0, -1)); } exports.default = parent;