jstests/aggregation/extras/window_function_helpers.js
/**
 * Helper to calculate the correct skip based on the lowerBound given.
 */
Helper to calculate the correct skip based on the lowerBound given.
Helper to calculate the correct skip based on the lowerBound given .
function calculateSkip(lowerBound, indexInPartition) {
    let skipValueToUse = 0;
    if (lowerBound === "current") {
        skipValueToUse = indexInPartition;
    } else if (lowerBound === "unbounded") {
        skipValueToUse = 0;
    } else {
        skipValueToUse = indexInPartition + lowerBound;
        if (skipValueToUse < 0) {
            skipValueToUse = 0;
        }
    }
    return skipValueToUse;
}
function calculateSkip ( lowerBound , indexInPartition ) { let skipValueToUse = 0 ; if ( lowerBound === "current" ) { skipValueToUse = indexInPartition ; } else if ( lowerBound === "unbounded" ) { skipValueToUse = 0 ; } else { skipValueToUse = indexInPartition + lowerBound ; if ( skipValueToUse < 0 ) { skipValueToUse = 0 ; } } return skipValueToUse ; }
Helper to calculate the correct skip based on the lowerBound given.
Helper to calculate the correct skip based on the lowerBound given .