Wraps array for grid access. Mutable, meaning that array gets modified if set function is used.

const g = wrapMutable(myArray, 5); // 5 columns wide
g.get({x:1,y:2}); // Get value at cell position
g.set(10, {x:1,y:2}); // Set value at cell position
g.array; // Get reference to original passed-in array

Use wrap for an immutable version.

  • Type Parameters

    • T

    Parameters

    • array: T[]

      Array to wrap

    • cols: number

      Width of grid

    Returns GridArray1d<T>