Grid reducers

What are reducers?

Reducers take a grid instance and reduce it to a single value.

import {createGridFromArray2D} from "gridl/core";
import {reduceGrid} from "gridl/reducers";

const grid = createGridFromArray2D([
    [1, 2, 3],
    [4, 5, 6],
]);
const initialValue = 10;
const sum = reduceGrid(grid, (acc, cellValue: number) => {
    return acc + cellValue;
}, initialValue);
// => 31 (10 + 1 + 2 + 3 + 4 + 5 + 6)