mrr.sj.front/node_modules/mingo/dist/esm/operators/window/shift.js

13 lines
442 B
JavaScript
Raw Normal View History

2026-03-25 15:27:45 +08:00
import { computeValue } from "../../core";
const $shift = (obj, collection, expr, options) => {
const input = expr.inputExpr;
const shiftedIndex = expr.documentNumber - 1 + input.by;
if (shiftedIndex < 0 || shiftedIndex > collection.length - 1) {
return input.default ? computeValue(obj, input.default, null, options) : null;
}
return computeValue(collection[shiftedIndex], input.output, null, options);
};
export {
$shift
};