All files / src/shared SortPart.ts

31.25% Statements 5/16
0% Branches 0/5
0% Functions 0/4
38.46% Lines 5/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29      1x     1x     1x           1x     1x                    
// Package: com.lightningkite.lightningdb
// Generated by Khrysalis - this file will be overwritten.
import { PartialDataClassProperty } from './DataClassProperty'
import { Comparator, ReifiedType, compareBy, setUpDataClass } from '@lightningkite/khrysalis-runtime'
 
//! Declares com.lightningkite.lightningdb.SortPart
export class SortPart<T extends any> {
    public constructor(public readonly field: PartialDataClassProperty<T>, public readonly ascending: boolean = true) {
    }
    public static properties = ["field", "ascending"]
    public static propertyTypes(T: ReifiedType) { return {field: [String, T], ascending: [Boolean]} }
    copy: (values: Partial<SortPart<T>>) => this;
    equals: (other: any) => boolean;
    hashCode: () => number;
}
setUpDataClass(SortPart)
 
//! Declares com.lightningkite.lightningdb.comparator>kotlin.collections.Listcom.lightningkite.lightningdb.SortPartcom.lightningkite.lightningdb.comparator.T
export function xListComparatorGet<T extends any>(this_: Array<SortPart<T>>): (Comparator<T> | null) {
    Iif (this_.length === 0) { return null }
    return (a: T, b: T): number => {
        for (const part of this_) {
            const result = compareBy(part.field as keyof T)!!(a, b);
            Iif (!(result === 0)) { return part.ascending ? result : (-result) }
        }
        return 0;
    };
}