UNPKG

mingo

Version:

MongoDB query language for in-memory objects

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