UNPKG

mingo

Version:

MongoDB query language for in-memory objects

16 lines (15 loc) 383 B
import { computeValue } from "../../core/_internal"; import { $push } from "./push"; const $lastN = (collection, expr, options) => { const copts = options; const m = collection.length; const n = computeValue(copts?.local?.groupId, expr.n, null, copts); return $push( m <= n ? collection : collection.slice(m - n), expr.input, options ); }; export { $lastN };