LInQer-ts

The C# Language Integrated Queries ported for Javascript for amazing performance

npm version License: MIT

Installation

$ npm install @siderite/linqer-ts

Quick start

const source = ... an array or a generator function or anything that is iterable... ;
const enumerable = Enumerable.from(source); // now you can both iterate and use LINQ like functions
const result = enumerable
                .where(item=>!!item.value) // like filter
                .select(item=>{ value: item.value, key: item.name }) // like map
                .groupBy(item=>item.key)
                .where(g=>g.length>10)
                .orderBy(g=>g.key)
                .selectMany()
                .skip(15)
                .take(5);
for (const item of result) ...

in Node.js you have to prepend:

const Enumerable = require('@siderite/linqer');

in browser you have to load linqer.umd.js:

<script src="https://siderite.github.io/LInQer-ts/dist/linqer.umd.js"></script>

in Typescript, use:

import Enumerable from '@siderite/linqer-ts';

Licence

MIT

Array functions in Javascript create a new array for each operation, which is terribly wasteful. Using iterators and generator functions and objects, we can limit the operations to the items in the array that interest us, not all of them.

Blog post

https://siderite.dev/blog/linq-in-javascript-linqer. Leave comments there or add Issues on GitHub for feedback and support.

Hosted

Find it hosted on GitHub Pages and use it freely in your projects at:

Reference

Reference Linqer.js for the basic methods:

Original Enumerable .NET class

The original C# class can be found here: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable .

Building the solution

The library has been ported to Typescript. Run npm run build to create the .js files from the .ts code and run npm run doc to generate documentation to the docs folder