Comments (5)
It seems working, thanks!
from linqtotypescript.
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.
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.
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.
I did a quick release that should allow passing in generator functions - like from(foo)
from linqtotypescript.
Related Issues (18)
- Potential security vulnerability found in the hoek dependency HOT 1
- how to use select with chained groupby HOT 2
- max() on empty sequence from array throws HOT 3
- functions GroupJoin, DefaultIfEmpty are not available HOT 3
- orderBy<number> with default comparer uses string-based sort order HOT 1
- The library is great but does not work with React. Please Fix !!! HOT 3
- Running into issues with React HOT 5
- Unsupported engine for Node v16? HOT 3
- IEnumerable Min returns wrong result HOT 3
- Performance comparison/measurements HOT 2
- Support for LINQ to SQL HOT 1
- Question about the need for ECMAScript 2022 HOT 1
- Node.js 20 LTS compatibility HOT 4
- esbuild outerLoop' error HOT 7
- Support typescript 3.7 HOT 2
- "Cannot find module 'linq-to-typescript'" with @testing-library/react HOT 2
- LINQ .concat conflicts with native Typescript / Javascript .concat method HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linqtotypescript.