Packages

A web application in pursuit of meaning in life.

Retired package: Complete rewrite, scratch old versions

Current section

Files

Jump to
udia assets node_modules mout src array take.js
Raw

assets/node_modules/mout/src/array/take.js

define(function () {
/**
* Iterates over a callback a set amount of times
* returning the results
*/
function take(n, callback, thisObj){
var i = -1;
var arr = [];
if( !thisObj ){
while(++i < n){
arr[i] = callback(i, n);
}
} else {
while(++i < n){
arr[i] = callback.call(thisObj, i, n);
}
}
return arr;
}
return take;
});