tyneq / createOrderedOperator
Function: createOrderedOperator()
createOrderedOperator<
TSource,TArgs>(config):void
Defined in: src/plugin/registration/createOrderedOperator.ts:48
Registers a factory function as an operator available only on ordered sequences, where the factory fully controls the return type.
Use this when the operator must return a TyneqOrderedSequence (e.g. a thenBy variant). The factory receives the ordered source and a query plan node. It is responsible for constructing and returning the result sequence - typically by instantiating TyneqOrderedEnumerable directly.
For operators that return a plain sequence from an enumerator class, use @orderedOperator.
Type Parameters
| Type Parameter |
|---|
TSource |
TArgs extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | { name: string; category: "streaming" | "buffer"; factory: (source, node, ...args) => TyneqOrderedSequence<TSource>; validate?: (...args) => void; source?: OperatorSource; } | - |
config.name | string | Method name to expose on ordered sequences. |
config.category | "streaming" | "buffer" | Operator kind ("streaming" |
config.factory | (source, node, ...args) => TyneqOrderedSequence<TSource> | Constructs the result sequence from (source, node, ...userArgs). |
config.validate? | (...args) => void | Optional eager validation function for user-supplied arguments. |
config.source? | OperatorSource | - |
Returns
void
Example
ts
createOrderedOperator({
name: "thenByLocale",
category: "buffer",
factory: (source, node, locale: string, keySelector: (item: unknown) => string) =>
new TyneqOrderedEnumerable(
source.source,
keySelector,
(a, b) => a.localeCompare(b, locale),
false,
source,
node
),
validate: (locale, keySelector) => {
if (typeof locale !== "string") throw new Error("locale must be a string");
if (typeof keySelector !== "function") throw new Error("keySelector must be a function");
}
});