* Creates a function that wraps `func` to invoke it with the `this` binding * of `thisArg` and `partials` prepended to the arguments it receives. * * @private * @param {Function} func The function to wrap. * @param {number} bitmask The bitmask flags. See `createWrap` for mor
(func, bitmask, thisArg, partials)
| 5390 | * @returns {Function} Returns the new wrapped function. |
| 5391 | */ |
| 5392 | function createPartial(func, bitmask, thisArg, partials) { |
| 5393 | var isBind = bitmask & WRAP_BIND_FLAG, |
| 5394 | Ctor = createCtor(func); |
| 5395 | |
| 5396 | function wrapper() { |
| 5397 | var argsIndex = -1, |
| 5398 | argsLength = arguments.length, |
| 5399 | leftIndex = -1, |
| 5400 | leftLength = partials.length, |
| 5401 | args = Array(leftLength + argsLength), |
| 5402 | fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; |
| 5403 | |
| 5404 | while (++leftIndex < leftLength) { |
| 5405 | args[leftIndex] = partials[leftIndex]; |
| 5406 | } |
| 5407 | while (argsLength--) { |
| 5408 | args[leftIndex++] = arguments[++argsIndex]; |
| 5409 | } |
| 5410 | return apply(fn, isBind ? thisArg : this, args); |
| 5411 | } |
| 5412 | return wrapper; |
| 5413 | } |
| 5414 | |
| 5415 | /** |
| 5416 | * Creates a `_.range` or `_.rangeRight` function. |
no test coverage detected