jussi-kalliokoski / trine

A utility library for modern JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeat

ivoreis opened this issue · comments

Any special reason why the repeat is an infinite loop and doesn't accept a limit?

Is it useful to have both versions?

[1,2]::repeatLoop() => [1,2,1,2,1,2...]

[1,2]::repeat(2) => [1,2,1,2]

Hmm. The assumption is that you limit the results using head(), but that may not be practical if you actually want the set repeated N times instead of just getting N results.

Another options is that we could take a non-optional argument that can be set to Infinity for an infinite repetition. WDYT?

I know but for the stuff I was doing having a limited repeat made more sense.

If you thing about intent I guess would be more clear splitting both definitions and not having an argument controlling the flow. I guess in the end is just a matter of personal preference. From the top of your head any pros and cons about both options?