How to use linq-to-typescript - 10 common examples

To help you get started, we’ve selected a few linq-to-typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arogozine / LinqToTypeScript / nodetest / index.ts View on Github external
import { range } from "linq-to-typescript"

const primeNumbers = range(2, 10000)
    .select((i) => [i, Math.floor(Math.sqrt(i))])
    .where(([i, iSq]) =>
        range(2, iSq).all((j) => i % j !== 0))
    .select(([prime]) => prime)
    .toArray()

async function asyncIterable() {
    for await (const i of  range(0, 10).selectAsync(async (x) => x * 2)) {
        console.log(i)
    }
}

asyncIterable()
console.log(primeNumbers)
github arogozine / LinqToTypeScript / nodetest / index.ts View on Github external
async function asyncIterable() {
    for await (const i of  range(0, 10).selectAsync(async (x) => x * 2)) {
        console.log(i)
    }
}
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
function asParallel(type: ParallelGeneratorType, values: T[]): IParallelEnumerable {
    const generator1 = () =>
        values.map((value) => new Promise((resolve) => setTimeout(() => resolve(value), 10)))
    const generator2 = () =>
        new Promise((resolve) => setTimeout(() => resolve([... values]), 10))
    const generator3 = async () =>
        await generator1()
    switch (type) {
        case ParallelGeneratorType.ArrayOfPromises:
            return fromParallel(type, generator1)
        case ParallelGeneratorType.PromiseToArray:
            return fromParallel(type, generator2)
        case ParallelGeneratorType.PromiseOfPromises:
        default:
            return fromParallel(type, generator3)
    }

}
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
function asParallel(type: ParallelGeneratorType, values: T[]): IParallelEnumerable {
    const generator1 = () =>
        values.map((value) => new Promise((resolve) => setTimeout(() => resolve(value), 10)))
    const generator2 = () =>
        new Promise((resolve) => setTimeout(() => resolve([... values]), 10))
    const generator3 = async () =>
        await generator1()
    switch (type) {
        case ParallelGeneratorType.ArrayOfPromises:
            return fromParallel(type, generator1)
        case ParallelGeneratorType.PromiseToArray:
            return fromParallel(type, generator2)
        case ParallelGeneratorType.PromiseOfPromises:
        default:
            return fromParallel(type, generator3)
    }

}
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
function asParallel(type: ParallelGeneratorType, values: T[]): IParallelEnumerable {
    const generator1 = () =>
        values.map((value) => new Promise((resolve) => setTimeout(() => resolve(value), 10)))
    const generator2 = () =>
        new Promise((resolve) => setTimeout(() => resolve([... values]), 10))
    const generator3 = async () =>
        await generator1()
    switch (type) {
        case ParallelGeneratorType.ArrayOfPromises:
            return fromParallel(type, generator1)
        case ParallelGeneratorType.PromiseToArray:
            return fromParallel(type, generator2)
        case ParallelGeneratorType.PromiseOfPromises:
        default:
            return fromParallel(type, generator3)
    }

}
github arogozine / LinqToTypeScript / nodetest / index.ts View on Github external
.where(([i, iSq]) =>
        range(2, iSq).all((j) => i % j !== 0))
    .select(([prime]) => prime)
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
function asParallel(type: ParallelGeneratorType, values: T[]): IParallelEnumerable {
    const generator1 = () =>
        values.map((value) => new Promise((resolve) => setTimeout(() => resolve(value), 10)))
    const generator2 = () =>
        new Promise((resolve) => setTimeout(() => resolve([... values]), 10))
    const generator3 = async () =>
        await generator1()
    switch (type) {
        case ParallelGeneratorType.ArrayOfPromises:
            return fromParallel(type, generator1)
        case ParallelGeneratorType.PromiseToArray:
            return fromParallel(type, generator2)
        case ParallelGeneratorType.PromiseOfPromises:
        default:
            return fromParallel(type, generator3)
    }

}
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
    const a = (x: T[]) => asParallel(ParallelGeneratorType.ArrayOfPromises, x)
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
        const b = (x: T[]) => asParallel(ParallelGeneratorType.PromiseOfPromises, x)
        const c = (x: T[]) => asParallel(ParallelGeneratorType.PromiseToArray, x)
github arogozine / LinqToTypeScript / test / TestHelpers.ts View on Github external
function asParallel(type: ParallelGeneratorType, values: T[]): IParallelEnumerable {
    const generator1 = () =>
        values.map((value) => new Promise((resolve) => setTimeout(() => resolve(value), 10)))
    const generator2 = () =>
        new Promise((resolve) => setTimeout(() => resolve([... values]), 10))
    const generator3 = async () =>
        await generator1()
    switch (type) {
        case ParallelGeneratorType.ArrayOfPromises:
            return fromParallel(type, generator1)
        case ParallelGeneratorType.PromiseToArray:
            return fromParallel(type, generator2)
        case ParallelGeneratorType.PromiseOfPromises:
        default:
            return fromParallel(type, generator3)
    }

}