SkillAgentSearch skills...

LinqToTypeScript

LINQ to TypeScript

Install / Use

/learn @arogozine/LinqToTypeScript
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

LINQ To TypeScript

  • Implementation of LINQ for TypeScript
  • Targets TypeScript 5.6.X and ES 2022
await from([bing, google, quackQuackGo])
    .asParallel()
    .selectAsync(downloadHtml)
    .select(getTitle)
    .toArray()

Getting Started

npm i linq-to-typescript

npm npm bundle size License npm

tsconfig.json

"compilerOptions": {
    "target": "es2022",
    "lib": [
      "es2022"
    ]
}
  • The strict TS option is recommended.

Using the Library

With Wrappers

// 0. Import Module
import { from } from "linq-to-typescript"

// To Use With Wrappers
const evenNumbers = from([1, 2, 3, 4, 5, 6, 7, 8, 9]).where((x) => x % 2 === 0).toArray()

Without Wrappers

// 0. Import Module
import { initializeLinq, IEnumerable } from "linq-to-typescript"
// 1. Declare that the JS types implement the IEnumerable interface
declare global {
    interface Array<T> extends IEnumerable<T> { }
    interface Uint8Array extends IEnumerable<number> { }
    interface Uint8ClampedArray extends IEnumerable<number> { }
    interface Uint16Array extends IEnumerable<number> { }
    interface Uint32Array extends IEnumerable<number> { }
    interface Int8Array extends IEnumerable<number> { }
    interface Int16Array extends IEnumerable<number> { }
    interface Int32Array extends IEnumerable<number> { }
    interface Float32Array extends IEnumerable<number> { }
    interface Float64Array extends IEnumerable<number> { }
    interface Map<K, V> extends IEnumerable<[K, V]> { }
    interface Set<T> extends IEnumerable<T> { }
    interface String extends IEnumerable<string> { }
}
// 2. Bind Linq Functions to Array, Map, etc
initializeLinq()
// 3. Use without a wrapper type
const evenNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9].where((x) => x % 2 === 0).toArray()

Examples

Please refer to the examples folder

ES6 Modules (ESM)

To use library with ES6 modules make sure that you specify "type": "module" in package.json

API

TypeDoc API Surface Documentation

LinqToTypeScript implements the functionality of the IEnumerable interface

  • IEnumerable, IAsyncEnumerable, and IParallelEnumerable interfaces are based on,
  • IEnumerable<T> Interface
  • Some changes made due to conflics with existing method names
  • Some changes made due to limitations of JavaScript

IEnumerable

  • Inspired by LINQ API Surface
  • Has Async methods that return Promise or IAsyncEnumerable
  • Implements Iterable<T>
  • Use from to wrap your arrays

IAsyncEnumerable

  • Inspired by LINQ API Surface
  • Has Async methods that return Promise or IAsyncEnumerable
  • For asynchronous iteration
  • Implements AsyncIterable<T> interface
  • Use fromAsync to wrap your AsyncIterable type

IParallelEnumerable

  • Inspired by LINQ API Surface
  • Has Async methods that return Promise or IParallelEnumerable
  • For asynchronous iteration in parallel (where possible)
  • Implements AsyncIterable<T> interface
  • Use fromParallel to create a parallel enumeration

Shared Instance Methods

| Method | Async* | Tests Coverage | Notes | |--------------------|---------|----------------|-------| | aggregate | No | Sync | all | Yes | Sync, Async | any | Yes | Sync, Async | append | No | Sync | average | Yes | Sync, Async | chunk | No | Sync | concatenate | No | Sync | Equivalent to .Concat but renamed to avoid conflict with JS | contains | Yes | Sync, Async | count | Yes | Sync, Async | defaultIfEmpty | No | Sync | distinct | Yes | Sync, Async | elementAt | No | Sync | elementAtOrDefault | No | Sync | except | Yes | Sync, Async | first | Yes | Sync, Async | firstOrDefault | Yes | Sync, Async | each | Yes | Sync, Async | From List<T>.ForEach | groupBy | Yes | Sync, Async | groupByWithSel | No | Sync | groupJoin | Yes | Sync, Async | intersect | Yes | Sync, Async | joinByKey | No | Sync | last | Yes | Sync, Async | lastOrDefault | Yes | Sync, Async | max | Yes | Sync, Async | min | Yes | Sync, Async | ofType | No | Sync | order | No | Sync | orderBy | Yes | Sync, Async | orderByDescending |

Related Skills

View on GitHub
GitHub Stars155
CategoryDevelopment
Updated14d ago
Forks19

Languages

TypeScript

Security Score

95/100

Audited on Mar 15, 2026

No findings