tomi / fromfrom

A JS library written in TS to transform sequences of data from format to another
MIT License
480 stars 9 forks source link

how about a simple range generator? #110

Open jmagaram opened 3 years ago

jmagaram commented 3 years ago

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?

tomi commented 3 years ago

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()