1 |
|
2 |
|
3 | /**
|
4 | * Iterates over a callback a set amount of times
|
5 | * returning the results
|
6 | */
|
7 | function take(n, callback, thisObj){
|
8 | var i = -1;
|
9 | var arr = [];
|
10 | if( !thisObj ){
|
11 | while(++i < n){
|
12 | arr[i] = callback(i, n);
|
13 | }
|
14 | } else {
|
15 | while(++i < n){
|
16 | arr[i] = callback.call(thisObj, i, n);
|
17 | }
|
18 | }
|
19 | return arr;
|
20 | }
|
21 |
|
22 | module.exports = take;
|
23 |
|
24 |
|