* Creates a function that invokes `func`, with the `this` binding and arguments * of the created function, while it's called less than `n` times. Subsequent * calls to the created function return the result of the last `func` invocation. * * @static * @me
(n, func)
| 20667 | * // => Allows adding up to 4 contacts to the list. |
| 20668 | */ |
| 20669 | function before(n, func) { |
| 20670 | var result; |
| 20671 | if (typeof func != 'function') { |
| 20672 | throw new TypeError(FUNC_ERROR_TEXT); |
| 20673 | } |
| 20674 | n = toInteger(n); |
| 20675 | return function() { |
| 20676 | if (--n > 0) { |
| 20677 | result = func.apply(this, arguments); |
| 20678 | } |
| 20679 | if (n <= 1) { |
| 20680 | func = undefined; |
| 20681 | } |
| 20682 | return result; |
| 20683 | }; |
| 20684 | } |
| 20685 | |
| 20686 | /** |
| 20687 | * Creates a function that invokes `func` with the `this` binding of `thisArg` |
no test coverage detected