#LINQ
Exported in this module is the Enumerable class which contains
all available LINQ methods you would expect.
Because the notion of 'extensions' in JavaScript is not a simple and elegant as C#, it was important to allow for flexibility of use.
Enumerable.from(source) will return an Enumerable wrapper for LINQ access to the source.
Source values that work:
- Any object which has a
.getEnumerator()method attached to it. SeeIEnumeratorin System/Collections/Enumerable. - Arrays or objects analogous to arrays (have a
.lengthproperty and index by number).
import Enumerable from '[path or alias to source folder]/System.Linq/Linq';
var sourceData = ['a','b','c','c','d'];
var myEnumerable = Enumerable.from(sourceData);
console.log(
myEnumerable.count(x=>x=='c'), // 2
myEnumerable.any(x=>x=='e'), // false
);require('[path or alias to source folder]/System.Linq/Linq',function(Enumerable){
var sourceData = ['a','b','c','c','d'];
var myEnumerable = Enumerable.from(sourceData);
console.log(
myEnumerable.count(function(x){return x=='c'}), // 2
myEnumerable.any(function(x){return x=='e'}), // false
);
});var Enumerable = require('[path or alias to source folder]/System.Linq/Linq');
var sourceData = ['a','b','c','c','d'];
var myEnumerable = Enumerable.from(sourceData);
console.log(
myEnumerable.count(function(x){return x=='c'}), // 2
myEnumerable.any(function(x){return x=='e'}), // false
);