UNPKG

mingo

Version:

MongoDB query language for in-memory objects

19 lines (18 loc) 572 B
import { computeValue } from "../../../core/_internal"; import { assert, isArray, isNil, isString } from "../../../util"; import { errExpectArray } from "../_internal"; const $concat = (obj, expr, options) => { assert(isArray(expr), "$concat expects array"); const foe = options.failOnError; const args = computeValue(obj, expr, null, options); let ok = true; for (const s of args) { if (isNil(s)) return null; ok &&= isString(s); } if (!ok) return errExpectArray(foe, "$concat", { type: "string" }); return args.join(""); }; export { $concat };