UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

35 lines (34 loc) 1.32 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const isArray_1 = __importDefault(require("../isArray")); const baseMatchesProperty_1 = __importDefault(require("./baseMatchesProperty")); const baseMatches_1 = __importDefault(require("./baseMatches")); const property_1 = __importDefault(require("../property")); const identity_1 = __importDefault(require("./identity")); /** * The base implementation of `iteratee`. * * @private * @param {*} [value=identity] The value to convert to an iteratee. * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. if (typeof value == 'function') { return value; } if (value == null) { return identity_1.default; } if (typeof value == 'object') { return (0, isArray_1.default)(value) ? (0, baseMatchesProperty_1.default)(value[0], value[1]) : (0, baseMatches_1.default)(value); } return (0, property_1.default)(value); } exports.default = baseIteratee;