mingo
Version:
MongoDB query language for in-memory objects
16 lines (15 loc) • 449 B
JavaScript
import { computeValue } from "../../../core/_internal";
import { assert, isArray } from "../../../util";
import { truncate } from "./_internal";
const $round = (obj, expr, options) => {
assert(isArray(expr), "$round expects array(2)");
const [n, precision] = computeValue(obj, expr, null, options);
return truncate(n, precision ?? 0, {
name: "$round",
roundOff: true,
failOnError: options.failOnError
});
};
export {
$round
};