Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / baseCallback.js
1 var baseMatches = require('./baseMatches'),
2     baseMatchesProperty = require('./baseMatchesProperty'),
3     bindCallback = require('./bindCallback'),
4     identity = require('../utility/identity'),
5     property = require('../utility/property');
6
7 /**
8  * The base implementation of `_.callback` which supports specifying the
9  * number of arguments to provide to `func`.
10  *
11  * @private
12  * @param {*} [func=_.identity] The value to convert to a callback.
13  * @param {*} [thisArg] The `this` binding of `func`.
14  * @param {number} [argCount] The number of arguments to provide to `func`.
15  * @returns {Function} Returns the callback.
16  */
17 function baseCallback(func, thisArg, argCount) {
18   var type = typeof func;
19   if (type == 'function') {
20     return thisArg === undefined
21       ? func
22       : bindCallback(func, thisArg, argCount);
23   }
24   if (func == null) {
25     return identity;
26   }
27   if (type == 'object') {
28     return baseMatches(func);
29   }
30   return thisArg === undefined
31     ? property(func)
32     : baseMatchesProperty(func, thisArg);
33 }
34
35 module.exports = baseCallback;