isc30 / linq-collections

Strongly typed Linq and Collections implementation for Javascript and TypeScript (ECMAScript 5)
https://www.npmjs.com/package/linq-collections
MIT License
119 stars 12 forks source link

ES6 iterators - enable ForOf for collections #47

Closed vdolek closed 4 years ago

vdolek commented 4 years ago

This PR implements ES6 iterators for all collections in the library. It enables using ForOf with collections without using toArray() method.

Example:

const list = new List([1, 2, 3]);
for (const item of list) {
    console.log(item);
}

Besides that it allows using collections with *ngFor in Angular without using toArray() method.

vdolek commented 4 years ago

Hi @isc30, will you be able to review and possibly merge and publish this PR?

isc30 commented 4 years ago

Hi there, this lib aims for ES5 compatibility and it has no Symbol.Iterator due to this limitation. If you want, you can publish your fork in NPM as Linq-Collections-ES6 and get these new features rolling there!

vdolek commented 4 years ago

In the end this PR is published separately in https://www.npmjs.com/package/linq-collections-es6.

isc30 commented 4 years ago

Awesome! Thanks a lot