Skip to content
/ LINQ Public

TypeScript Implementation of Language-Integrated Query (LINQ) (ECMAScript 2015)

License

Notifications You must be signed in to change notification settings

ENikS/LINQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 21, 2016
e046b78 · Jul 21, 2016
Jul 17, 2016
Jul 21, 2016
Jul 20, 2016
Jun 24, 2016
Jun 30, 2016
Jun 30, 2016
Jul 17, 2016
Jul 17, 2016
Jul 20, 2016
Jul 17, 2016
Jun 6, 2015
Jul 20, 2016
Jul 20, 2016
Jul 17, 2016
Jul 21, 2016
Jul 20, 2016

Repository files navigation

Build Status Coverage Status Dependency Status npm version Downloads

The library is a continuous effort to implement LINQ using latest features of TypeScript and JavaScript languages (For ES5 compatible library look at linq-es5 branch). The library is implemented in TypeScript and transpiled into JavaScript. It is distributed as a native node module. Browserified and minified standalone UMD modules are located in ./dist directory and could be used directly in compatible browsers. This library uses latest ECMAScript 2015 language specification and utilizes Iterables: ( [System.iterator] ), JavaScript generators (function*), and for of loops. All relevant methods are implemented with deferred execution so no unnecessary iterations are performed. The code is backwards compatible with linq-es5 and C# implementations.

Using

import * as Enumerable from "linq-es2015";

var count =  Enumerable.asEnumerable( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
                       .Where(a => a % 2 == 1)
                       .Count()

var iterable = Enumerable.asEnumerable(people)
                         .GroupJoin(pets,
                                    person => person, 
                                    pet => pet.Owner,
                                    (person, petCollection) => {
                                        return {
                                            Owner: person.Name,
                                            Pets: asEnumerable(petCollection)
                                                 .Select(pet=> pet.Name)
                                                 .ToArray()
                                        };
                                    });

For live examples please follow links to (Node) or (Browser).

Naming Convention

When library is used in TypeScript method names follow original C# convention (Name starts with capital letter). It is done for compatibility reasons so that code could be cut/pasted from C# with just minor reformatting. If used directly in JavaScript names follow camelCase notation.

Documentation