five icon indicating copy to clipboard operation
five copied to clipboard

Consider adding five.times()

Open sigriston opened this issue 9 years ago • 1 comments

It would be really handy to have a five.times() function that does the following:

  • If a number x is passed to it, calculate five() * x
  • If a function f is passed to it, execute it five times

sigriston avatar Sep 22 '16 17:09 sigriston

five.times = function(entity){
    if(typeof entity === "number")
        return five() * entity;

    if(typeof entity === "string")
        return entity.repeat(five());

    if(typeof entity === "function")
        for(let i = five() - five();
                i < five();
                i += five() / five())
            entity(i);

    // because you can't have enough five.
    return five();
}

ConorOBrien-Foxx avatar Sep 22 '16 23:09 ConorOBrien-Foxx