Skip to content

antmx/LinqArrayTS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript LinqArray<T>

A TypeScript generic array that supports .NET Language Integrated Query (LINQ) operations

TypeScript code example

import LinqArray from "../src/LinqArray";

let jsItems = [2, 4, 6, 8, 1, 3, 5, 7]; // Standard JS array of numbers
let items1 = new LinqArray<number>(jsItems); // items1 is of type LinqArray<number>, constructed from the standard JS array of numbers
let items2 = new LinqArray(jsItems); // Simplified constructor where generic type (number) is inferred from the source array

let firstOver4Times10 = items2
  .where((i) => i > 4) // items > 4
  .select((i) => i * 10) // multiply by 10
  .orderBy((i) => i) // order ascending
  .first(); // first item

let expected = 50;

expect(firstOver4Times10).toEqual(expected);

LinqArray includes equivalents of these common .NET LINQ, Generic and Array methods:

About

A TypeScript generic array that supports .NET Language Integrated Query (LINQ) operations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors