e371dab9e76de11b451cd2ed7459e0fddaa1270e
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / apply.js
1 /**
2  * A faster alternative to `Function#apply`, this function invokes `func`
3  * with the `this` binding of `thisArg` and the arguments of `args`.
4  *
5  * @private
6  * @param {Function} func The function to invoke.
7  * @param {*} thisArg The `this` binding of `func`.
8  * @param {...*} [args] The arguments to invoke `func` with.
9  * @returns {*} Returns the result of `func`.
10  */
11 function apply(func, thisArg, args) {
12   var length = args ? args.length : 0;
13   switch (length) {
14     case 0: return func.call(thisArg);
15     case 1: return func.call(thisArg, args[0]);
16     case 2: return func.call(thisArg, args[0], args[1]);
17     case 3: return func.call(thisArg, args[0], args[1], args[2]);
18   }
19   return func.apply(thisArg, args);
20 }
21
22 module.exports = apply;