ccb6bf4b936f87acdb746d38a30d5e7c533185c0
[yaffs-website] / baseIteratee.js
1 var baseMatches = require('./baseMatches'),
2     baseMatchesProperty = require('./baseMatchesProperty'),
3     identity = require('../identity'),
4     isArray = require('../isArray'),
5     property = require('../property');
6
7 /**
8  * The base implementation of `_.iteratee`.
9  *
10  * @private
11  * @param {*} [value=_.identity] The value to convert to an iteratee.
12  * @returns {Function} Returns the iteratee.
13  */
14 function baseIteratee(value) {
15   var type = typeof value;
16   if (type == 'function') {
17     return value;
18   }
19   if (value == null) {
20     return identity;
21   }
22   if (type == 'object') {
23     return isArray(value)
24       ? baseMatchesProperty(value[0], value[1])
25       : baseMatches(value);
26   }
27   return property(value);
28 }
29
30 module.exports = baseIteratee;