Grid

Grid

Class which can be iterated over and produces json for each row

Constructor

new Grid(npopt)

Created either via call to Grid.create or Grid.namedValues, but class can be returned by Grid.module()

Parameters:
Name Type Attributes Description
np Object <optional>

named parameters

Properties
Name Type Attributes Description
data2d Array.<Array> <optional>

2d array, can be set after instance creation if necessary

calculatedProps Object <optional>

keys repesent the header, and the values should be functions that return the calculated value for that header for any object

Source:
Examples
const grid = Grid.create([["one", "two"], [1, 2]]);
for (const {json} of row) {
  Logger.log(json);  // {one: 1, two: 2}
}
// using calculatedProps
const grid = Grid.create([["one", "two"], [1, 2]], {
  sum (json) {
    // use header names as keys on json
    return json.one + json.two;
  }
});
for (const {json} of row) {
  Logger.log(json);  // {one: 1, two: 2, sum: 3}
}