tyneq / createCachedOperator
Function: createCachedOperator()
createCachedOperator<
TSource,TArgs>(config):void
Defined in: src/plugin/registration/createCachedOperator.ts:41
Registers a factory function as an operator available only on cached sequences, where the factory fully controls the return type.
Use this when the operator must return a TyneqCachedSequence. The factory receives the cached source and a query plan node. It is responsible for constructing and returning the result sequence.
For operators that return a plain sequence from an enumerator class, use @cachedOperator.
Type Parameters
| Type Parameter |
|---|
TSource |
TArgs extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | { name: string; category: "streaming" | "buffer"; factory: (source, node, ...args) => TyneqCachedSequence<TSource>; validate?: (...args) => void; source?: OperatorSource; } | - |
config.name | string | Method name to expose on cached sequences. |
config.category | "streaming" | "buffer" | Operator kind ("streaming" |
config.factory | (source, node, ...args) => TyneqCachedSequence<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
createCachedOperator({
name: "refreshWith",
category: "buffer",
factory: (source, node, newSource: Iterable<unknown>) => {
const seq = tyneqFrom(newSource);
return new TyneqCachedEnumerable(seq, node);
},
validate: (newSource) => {
if (newSource == null) throw new Error("newSource must not be null");
}
});