1
0
Fork 0

Calc: Add repeat{,Concat}

* src/calc/Calc.js (repeat, repeatConcat): Add methods.
master
Mike Gerwitz 2017-08-10 14:49:59 -04:00
parent 5d95d0eb80
commit 874a638c43
1 changed files with 26 additions and 0 deletions

View File

@ -663,6 +663,32 @@ exports.value = function( data, indexes )
};
exports.repeat = function( data, value )
{
var times = value[ 0 ] || 0;
var result = [];
while ( times-- > 0 )
{
result.push( data );
}
return result;
};
exports.repeatConcat = function( data, value )
{
var times = value[ 0 ] || 0;
var result = [];
while ( times-- > 0 )
{
result = result.concat( data );
}
return result;
};
exports[ 'void' ] = function()
{
return [];