mingo
Version:
MongoDB query language for in-memory objects
19 lines (18 loc) • 415 B
JavaScript
import {
ComputeOptions,
computeValue
} from "../../core";
import { $push } from "./push";
const $firstN = (collection, expr, options) => {
const copts = ComputeOptions.init(options);
const m = collection.length;
const n = computeValue(copts?.local?.groupId, expr.n, null, copts);
return $push(
m <= n ? collection : collection.slice(0, n),
expr.input,
options
);
};
export {
$firstN
};