Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 4.74 KB

NPM.md

File metadata and controls

54 lines (40 loc) · 4.74 KB

Coverage Status Dependency Status License

Language-Integrated Query (LINQ)

linq-es2015 is a complete implementation of LINQ (Language-Integrated Query) pattern and enables you to express traversal, filter, and projection operations over data in JavaScript or any related programming languages (TypeScript, CoffeeScript, etc).
It provides an implementation of the standard query operators for querying any data source that implements Iterable. Methods that are used in a query that return a sequence of values do not consume the target data until the query object is enumerated. This is known as deferred execution. Methods that are used in a query that returns a singleton value execute and consume the target data immediately.

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 and corresponding NPM package). 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.

Installation

npm install linq-es2015

Using

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

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

Using in browser

Browserified standalone UMD module is located in ./dist directory and could be accessed through NPM CDN service. Both linq.js and linq.min.js are available.
[See Example]

Using in Angular

The same package could be used on a server as well as on the client. The package does not require any special handling and used as any other module. [See Example]

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

Example Projects