Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

_base-iteratee

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
687
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
7 KB
1 contributor
Install _base-iteratee as a package?
Copied
npm i @bit/lodash.lodash.internal._base-iteratee
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
_baseIteratee.js
31 Lines(20 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import baseMatches from './_baseMatches.js';
import baseMatchesProperty from './_baseMatchesProperty.js';
import identity from './identity.js';
import isArray from './isArray.js';
import property from './property.js';

/**
 * 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;
  }
  if (typeof value == 'object') {
    return isArray(value)
      ? baseMatchesProperty(value[0], value[1])
      : baseMatches(value);
  }
  return property(value);
}

export default baseIteratee;