UNPKG

mingo

Version:

MongoDB query language for in-memory objects

16 lines (15 loc) 450 B
import { computeValue } from "../../../core/_internal"; import { assert, isArray } from "../../../util"; import { truncate } from "./_internal"; const $trunc = (obj, expr, options) => { assert(isArray(expr), "$trunc expects array(2)"); const [n, precision] = computeValue(obj, expr, null, options); return truncate(n, precision ?? 0, { name: "$trunc", roundOff: false, failOnError: options.failOnError }); }; export { $trunc };