UNPKG

mingo

Version:

MongoDB query language for in-memory objects

11 lines (10 loc) 315 B
import { compare, isNil } from "../../util"; import { $push } from "./push"; const $max = (collection, expr, options) => { const items = $push(collection, expr, options).filter((v) => !isNil(v)); if (!items.length) return null; return items.reduce((r, v) => compare(r, v) >= 0 ? r : v); }; export { $max };