1
2
3
4
5
6
7
8
9
10
11
12
| // Returns a function that will only be executed up to (but not including) the
| // Nth call.
| export default function before(times, func) {
| var memo;
| return function() {
| if (--times > 0) {
| memo = func.apply(this, arguments);
| }
| if (times <= 1) func = null;
| return memo;
| };
| }
|
|