SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface ReduceOptions<U>

    Options for a fold — IRange.alignReduce.

    interface ReduceOptions<U = any> {
        axis?: TraversalAxis;
        bounds?: Partial<IRange.Coords>;
        coerce?: CoerceParams;
        emptyFold?: (accumulator: U, count: number) => U;
        errorOnInvalidCoercion?: boolean;
        includeEmpty?: boolean;
        onError?: "value" | "throw" | "ignore" | ((error: Known) => void);
        processColumnSkip?: (index: number, reverse?: boolean) => number;
        processRowSkip?: (index: number, reverse?: boolean) => number;
        reverse?: boolean;
        thisArg?: any;
        type?: ScalarType | null;
    }

    Type Parameters

    • U = any

    Hierarchy (View Summary)

    Index

    The direction of the iteration.

    IRange.Axis.Row

    If axis is set to 'fastest', the implementation will automatically choose the fastest axis for iteration based on the internal data layout of the range. This can provide performance benefits without requiring the caller to specify the axis, especially when the optimal axis is not known in advance.

    bounds?: Partial<IRange.Coords>

    The bounds of the iteration.

    The entire range

    coerce?: CoerceParams

    Overrides default coercion behavior per type. When a value cannot be coerced, onError determines the fallback.

    emptyFold?: (accumulator: U, count: number) => U

    Folds the positions the iteration never visited — the cells that are empty on EVERY side — in a single call, given how many there are.

    Type Declaration

      • (accumulator: U, count: number): U
      • Parameters

        • accumulator: U

          The accumulator after every visited position has been folded.

        • count: number

          How many positions of this range's shape went unvisited. Never 0: the fold is skipped entirely when the iteration was dense.

        Returns U

    A sparse fold visits stored members only, which is the whole point of it and is why SUM(A:A) is not a million calls. But a reducer whose answer DEPENDS on the blanks — COUNTIF(A:A,"<>10") is 1,048,576 — needs their contribution, and iterating them to get it gives the cost back. The contribution is the same term repeated, so it is stated in closed form here and applied once.

    This is the caller's to supply because only the caller knows the fold: COUNTIF adds the count, SUMIF and MAXIFS are unchanged by a blank and pass nothing at all. It is the open-ufunc analogue of numpy's initial= — numpy hard-codes the identity per reduction because its set is closed, and this cannot.

    Omit it and the unvisited positions contribute nothing, which is the behavior every fold had before this option existed.

    errorOnInvalidCoercion?: boolean

    If true, coercion failure produces #VALUE! rather than silently skipping the value.

    false

    includeEmpty?: boolean

    If true will visit empty cells. This is a potentially huge performance improvement if set to false.

    false

    If includeEmpty is true this will always return rectangular results. If bounds are provided it will provide empty spaces before and after. If passing a large bound care must be taken.

    onError?: "value" | "throw" | "ignore" | ((error: Known) => void)

    What to do when the visited value is a FormulaError.

    throw

    'throw' = throw error. 'ignore' = silently skip the value. 'value' = return a specific error value (default #VALUE!). 'function' = custom handler; use this to return a specific error value.

    processColumnSkip?: (index: number, reverse?: boolean) => number

    Skips columns of the range, as processRowSkip skips rows.

    processRowSkip?: (index: number, reverse?: boolean) => number

    Skips rows of the range: given the next row that would be read, answers the row to read instead - the same row when it is read, or the next one that is (the previous, when reverse).

    Type Declaration

      • (index: number, reverse?: boolean): number
      • Parameters

        • index: number

          The 0-based row about to be read.

        • Optionalreverse: boolean

          Whether the read runs from the last row back.

        Returns number

        The row to read, at or past index.

    A skipped cell is not visited, reads as empty and is left out of the statistics; the shape of the range is unchanged. SUBTOTAL reads a range this way when it skips hidden rows.

    reverse?: boolean

    Iterate in reverse order.

    false

    thisArg?: any

    Useful for callback functions that want a this.

    type?: ScalarType | null

    Specifies the target type for coercion and filtering when getting or iterating values.

    The scalar type of the IRange itself (getType())

    • Values matching the type pass through unchanged.
    • Values coercible to the type are coerced.
    • If not set, the range's own scalar type (getType()) is used.
    • If the range has no scalar type, or set to null explicitly, no coercion or filtering is performed.