1.2.2 • Published 3 years ago

@cological/linq v1.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Linq

  • A simple library that mimics the C# Linq Enumerable for Typescript.

There are two formats

  1. The fluent format
  2. The piping format

Example using the fluent format:

import { enumerable } from '@cological/linq';

...

const groups =
    enumerable([1, 2, 3, 4])
        .orderByDescending(num => num)
        .groupBy(num => num % 2);

for (const group of groups) {
    console.log(group.key === 0 ? 'even' : 'odd');
    for (const num of group) {
        console.log(`    {num}`);
    }
}

Example using the piping format:

import { linq } from '@cological/linq';
import { groupBy, orderByDescending } from '@cological/linq/functions';

const groups = linq(
    [1, 2, 3, 4]
    orderByDescending(num => num),
    groupBy(num => num % 2)
);

for (const group of groups) {
    console.log(group.key === 0 ? 'even' : 'odd');
    for (const num of group) {
        console.log(`    {num}`);
    }
}
1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago