mingo
Version:
MongoDB query language for in-memory objects
14 lines (13 loc) • 421 B
JavaScript
import { computeValue } from "../../../core/_internal";
import { assert, isArray, isNil } from "../../../util";
const $reverseArray = (obj, expr, options) => {
const arr = computeValue(obj, expr, null, options);
if (isNil(arr)) return null;
assert(isArray(arr), "$reverseArray expression must resolve to an array");
const result = arr.slice(0);
result.reverse();
return result;
};
export {
$reverseArray
};