@newdash/newdash
Version:
javascript/typescript utility library
35 lines (34 loc) • 1.33 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isIterateeCall = void 0;
const eq_1 = __importDefault(require("../eq"));
const isArrayLike_1 = __importDefault(require("../isArrayLike"));
const isObject_1 = __importDefault(require("../isObject"));
const isIndex_1 = __importDefault(require("./isIndex"));
/**
* Checks if the given arguments are from an iteratee call.
*
* @private
* @param {*} value The potential iteratee value argument.
* @param {*} index The potential iteratee index or key argument.
* @param {*} object The potential iteratee object argument.
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
* else `false`.
*/
function isIterateeCall(value, index, object) {
if (!(0, isObject_1.default)(object)) {
return false;
}
const type = typeof index;
if (type === 'number'
? ((0, isArrayLike_1.default)(object) && (0, isIndex_1.default)(index, object.length))
: (type === 'string' && index in object)) {
return (0, eq_1.default)(object[index], value);
}
return false;
}
exports.isIterateeCall = isIterateeCall;
exports.default = isIterateeCall;