UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

30 lines (29 loc) 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.baseInvoke = void 0; const castPath_1 = __importDefault(require("./castPath")); const parent_1 = __importDefault(require("./parent")); const toKey_1 = __importDefault(require("./toKey")); const last_1 = __importDefault(require("../last")); const apply_1 = __importDefault(require("./apply")); /** * The base implementation of `invoke` without support for individual * method arguments. * * @private * @param {Object} object The object to query. * @param {Array|string} path The path of the method to invoke. * @param {Array} args The arguments to invoke the method with. * @returns {*} Returns the result of the invoked method. */ function baseInvoke(object, path, args) { path = (0, castPath_1.default)(path, object); object = (0, parent_1.default)(object, path); var func = object == null ? object : object[(0, toKey_1.default)((0, last_1.default)(path))]; return func == null ? undefined : (0, apply_1.default)(func, object, args); } exports.baseInvoke = baseInvoke; exports.default = baseInvoke;