How to use the @esfx/equatable.Comparer.create function in @esfx/equatable

To help you get started, we’ve selected a few @esfx/equatable 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 rbuckton / iterable-query / src / lib / fn / maxAsync.ts View on Github external
export async function maxAsync(source: AsyncQueryable, comparer: Comparison | Comparer = Comparer.defaultComparer): Promise {
    if (typeof comparer === "function") comparer = Comparer.create(comparer);
    assert.mustBeAsyncQueryable(source, "source");
    assert.mustBeComparer(comparer, "comparer");
    return maxByAsync(source, identity, comparer);
}
github rbuckton / iterable-query / src / lib / fn / orderBy.ts View on Github external
export function orderByDescending(source: Queryable, keySelector: (element: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): OrderedIterable {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBeQueryable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    return FlowHierarchy(new OrderByIterable(ToIterable(source), keySelector, keyComparer, /*descending*/ true), source);
}
github rbuckton / iterable-query / src / lib / fn / orderByAsync.ts View on Github external
export function orderByDescendingAsync(source: AsyncQueryable, keySelector: (element: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): AsyncOrderedIterable {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBeAsyncQueryable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    return FlowHierarchy(new AsyncOrderByIterable(ToPossiblyAsyncIterable(source), keySelector, keyComparer, /*descending*/ true), source);
}
github rbuckton / iterable-query / src / lib / fn / minAsync.ts View on Github external
export async function minAsync(source: AsyncQueryable, comparer: Comparison | Comparer = Comparer.defaultComparer): Promise {
    if (typeof comparer === "function") comparer = Comparer.create(comparer);
    assert.mustBeAsyncQueryable(source, "source");
    assert.mustBeComparer(comparer, "comparer");
    return minByAsync(source, identity, comparer);
}
github rbuckton / iterable-query / src / lib / fn / orderByAsync.ts View on Github external
[AsyncOrderedIterable.thenByAsync](keySelector: (element: T) => K, keyComparer: Comparison | Comparer, descending: boolean): AsyncOrderedIterable {
        if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
        assert.mustBeFunction(keySelector, "keySelector");
        assert.mustBeComparer(keyComparer, "keyComparer");
        assert.mustBeBoolean(descending, "descending");
        return new AsyncOrderByIterable(this._source, keySelector, keyComparer, descending, this);
    }
github rbuckton / iterable-query / src / lib / fn / orderByAsync.ts View on Github external
export function thenByDescendingAsync(source: PossiblyAsyncOrderedIterable, keySelector: (element: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): AsyncOrderedIterable {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBePossiblyAsyncOrderedIterable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    return FlowHierarchy(ThenByAsync(ToAsyncOrderedIterable(source), keySelector, keyComparer, /*descending*/ true), source);
}
github rbuckton / iterable-query / src / lib / fn / maxByAsync.ts View on Github external
export async function maxByAsync(source: AsyncQueryable, keySelector: (value: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): Promise {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBeAsyncQueryable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    let hasResult = false;
    let result: T | undefined;
    let resultKey: K | undefined;
    for await (const element of ToPossiblyAsyncIterable(source)) {
        const key = keySelector(element);
        if (!hasResult) {
            result = element;
            resultKey = key;
            hasResult = true;
        }
        else if (keyComparer.compare(key, resultKey!) > 0) {
            result = element;
            resultKey = key;
github rbuckton / iterable-query / src / lib / fn / orderByAsync.ts View on Github external
export function thenByAsync(source: PossiblyAsyncOrderedIterable, keySelector: (element: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): AsyncOrderedIterable {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBePossiblyAsyncOrderedIterable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    return FlowHierarchy(ThenByAsync(ToAsyncOrderedIterable(source), keySelector, keyComparer, /*descending*/ false), source);
}
github rbuckton / iterable-query / src / lib / fn / min.ts View on Github external
export function min(source: Queryable, comparer: Comparison | Comparer = Comparer.defaultComparer): T | undefined {
    if (typeof comparer === "function") comparer = Comparer.create(comparer);
    assert.mustBeQueryable(source, "source");
    assert.mustBeComparer(comparer, "comparer");
    return minBy(source, identity, comparer);
}
github rbuckton / iterable-query / src / lib / fn / minBy.ts View on Github external
export function minBy(source: Queryable, keySelector: (value: T) => K, keyComparer: Comparison | Comparer = Comparer.defaultComparer): T | undefined {
    if (typeof keyComparer === "function") keyComparer = Comparer.create(keyComparer);
    assert.mustBeQueryable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeComparer(keyComparer, "keyComparer");
    let hasResult = false;
    let result: T | undefined;
    let resultKey: K | undefined;
    for (const element of ToIterable(source)) {
        const key = keySelector(element);
        if (!hasResult) {
            result = element;
            resultKey = key;
            hasResult = true;
        }
        else if (keyComparer.compare(key, resultKey!) < 0) {
            result = element;
            resultKey = key;

@esfx/equatable

A low-level API for defining equality.

Apache-2.0
Latest version published 1 year ago

Package Health Score

45 / 100
Full package analysis

Similar packages