@tanstack/db
Version:
A reactive client store for building super fast apps on sync
19 lines (18 loc) • 703 B
JavaScript
import { Aggregate, ConditionalSelect, Func, isExpressionLike } from "../ir.js";
function findAggregate(value) {
if (value === null || typeof value !== `object`) return void 0;
if (Array.isArray(value)) {
for (const item of value) {
const aggregate = findAggregate(item);
if (aggregate) return aggregate;
}
return;
}
if (value instanceof Aggregate) return value;
if (value instanceof Func) return findAggregate(value.args);
if (value instanceof ConditionalSelect) return findAggregate([value.branches, value.defaultValue]);
if (isExpressionLike(value)) return void 0;
return findAggregate(Object.values(value));
}
export { findAggregate };
//# sourceMappingURL=find-aggregate.js.map