UNPKG

mingo

Version:

MongoDB query language for in-memory objects

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