fromfrom icon indicating copy to clipboard operation
fromfrom copied to clipboard

how about a simple range generator?

Open jmagaram opened this issue 3 years ago • 1 comments

I've come from C# and like your project. Couldn't find much out there (in TypeScript) like it - mystified by that! Would love to see just a simple fromRange(start:number, end:number) and maybe fromInfinite() to get me started. Or is there already some way to do that?

jmagaram avatar Feb 22 '21 00:02 jmagaram

Hi @jmagaram and thank you for your interest towards the project. That's an interesting idea. Currently it's not possible to do that with fromfrom. I think that should be quite easy to implement using a generator function:

function* range(start: number, end: number) {
  while (start < end) {
    yield start;
    start++;
  }
}

then you could use that with fromfrom

from(range(5, 10))
  .map(i => i * 2)
  .toArray()

tomi avatar Mar 06 '21 10:03 tomi