pond-ts API Reference (core)
    Preparing search index...

    Type Alias ReduceResult<S, Mapping>

    ReduceResult: {
        [K in keyof Mapping & string]: Mapping[K] extends {
            kind: infer ExplicitKind;
        }
            ? ValueForScalarKind<ExplicitKind>
            : Mapping[K] extends {
                from: infer From extends string;
                using: infer Using;
            }
                ? ReduceValueForReducer<S, From, Using>
                : ReduceValueForReducer<S, K, Mapping[K]>
    }

    Per-entry narrowed output type for TimeSeries.reduce(mapping). For an AggregateMap with literal reducer names, each field narrows to the specific value kind the reducer produces:

    series.reduce({ cpu: 'avg', host: 'unique' });
    // ^ { cpu: number | undefined;
    // host: ReadonlyArray<ScalarValue> | undefined }

    The branches are enumerated inline (rather than delegated to AggregateKindForColumn + NormalizedValueForKind) because the inlined form is the only shape TypeScript accepts in the same compilation unit as the arrayAggregate / arrayExplode overloads — more-delegated variants trip TS2394 on those overloads' compatibility with their implementation signature. The narrow logic is intentionally duplicated here; keep it in sync with AggregateKindForColumn in ./aggregate.ts if the set of numeric / array-producing reducers changes.

    Branches:

    • Numeric-output reducers ('sum', 'avg', 'count', 'median', 'stdev', 'difference', any p${number}) → number | undefined.
    • Array-output reducers ('unique', 'samples', any top${number}) → ReadonlyArray<T> | undefined, where T is the source column's element type — ReadonlyArray<string> for a kind: 'string' column, ReadonlyArray<number> for kind: 'number', etc. Array-kind source columns fall back to the wide ReadonlyArray<ScalarValue> | undefined.
    • Source-preserving reducers ('first', 'last', 'keep') → the source column's value type (number, string, or booleanundefined included). Array-kind source columns fall back to ColumnValue | undefined because tracking element kind is out of scope for the schema.
    • Spec entries ({ from, using }, { from, using, kind }) narrow the same way, sourcing the column kind from from rather than the key. An explicit kind on the spec widens to that kind's value type. Before v0.23.0 a spec entry in reduce fell back to the wide ColumnValue | undefined (audit v2 §5 F1) — it now narrows per reducer.
    • Custom reducer functions fall back to ColumnValue | undefined — their output kind is set at runtime and the type system can't see through it.

    The spec and shorthand branches share ReduceValueForReducer, which stays inline (nested conditionals, no delegation to schema-layer kind types) to keep the type compatible with the arrayAggregate / arrayExplode overloads' implementation signature — see the note above on TS2394.

    Type Parameters