Giter VIP home page Giter VIP logo

Comments (5)

levnach avatar levnach commented on June 16, 2024 1

It seems working, thanks!

from linqtotypescript.

arogozine avatar arogozine commented on June 16, 2024

I think that makes sense. You can only go forward with an iteration. So the first count iterates through all the values, giving nothing to iterate over for the second call to count.

In the next release (see dev branch) you should be able to do the following,

function* foo() { yield 0 }
const e2 = from(foo)
console.log(e2.count())
console.log(e2.count())

from linqtotypescript.

levnach avatar levnach commented on June 16, 2024

Sorry, your comment is not clear for me. Do you expect to get 1 at the second printout?
I noticed that you used foo without (). Do you expect output 1 in both cases? It would be great.

from linqtotypescript.

arogozine avatar arogozine commented on June 16, 2024

No to the first question. The iterator given by foo() can only move forward. So the first count() iterates through all the elements and gives the correct number but the second count() has nothing to iterate over so the number is 0. The library does not cache anything.

Yes to the second question. With the upcoming release - you can pass in the generator function itself - not the iterator given by the function - thus each count() calls foo() resulting in both being 1

Currently if you want to go from a generator, I'd suggest converting to an array [...foo()]

from linqtotypescript.

arogozine avatar arogozine commented on June 16, 2024

I did a quick release that should allow passing in generator functions - like from(foo)

from linqtotypescript.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.