UNPKG

mingo

Version:

MongoDB query language for in-memory objects

15 lines (14 loc) 407 B
import { computeValue } from "../../../core/_internal"; import { isNil } from "../../../util"; import { errExpectNumber } from "../_internal"; const $floor = (obj, expr, options) => { const n = computeValue(obj, expr, null, options); if (isNil(n)) return null; if (typeof n !== "number") { return errExpectNumber(options.failOnError, "$floor"); } return Math.floor(n); }; export { $floor };