UNPKG

mediatr-ts

Version:

Mimic the famous MediatR csharp library see: (https://github.com/jbogard/MediatR)

38 lines (37 loc) 1.09 kB
export type OrderedMapping<TData = object> = TData & { order?: number; }; /** * OrderedMappings is an abstract class that manages a collection of ordered mappings, * where each mapping has a specific order and associated data. * * @exports */ export declare abstract class OrderedMappings<TData = object> { protected _mappings: OrderedMapping<TData>[]; constructor(); /** * Adds a new mapping to the collection, automatically assigning an order if not provided ( defaults to the next available index). * @param mapping */ add(mapping: OrderedMapping<TData>): void; /** * Resets the collection by removing all existing mappings. */ clear(): void; /** * The mappings length * @returns The length */ get length(): number; } /** * Used to comapre elements in an ordered mapping * * @exports * * @param a The first element * @param b The second element * @returns The comparison result */ export declare function byOrder<TIdentifier>(a: OrderedMapping<TIdentifier>, b: OrderedMapping<TIdentifier>): number;