Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 1.88 KB

built-in-helper-functions.md

File metadata and controls

49 lines (28 loc) · 1.88 KB

Built-in Helper Functions

Cell Helpers

These functions return a cell's value or an array of cell values to be used in getter and setter functions.

Note: These helpers are the helper functions that you can supply at initialization that are wrapped to return cell values instead of the cells themselves. These helpers should not be used to supply cell arguments to setter helpers.

  • row(cellName)

    Returns a single cell's value from the current row by name

  • prevRow(cellName)

    Returns a single cell's value from the previous row by name

  • rowsWhere(criteria, cellName)

    Returns a cell's value from each row by name where criteria matches the metadata attributes found on each row. For example if I call rowsWhere({ color: red, even: true }, 'count') it will return the count cell from every row that has at least the color: red and even: true properties in the row's meta object.

    Note: ALL properties given in criteria must match for the row to match the rule and return it's cell.

Setter Helpers

These functions update cells based on the given values.

  • set(value, cells)

    Updates all cells with the given value. cells can either be a single cell or an array of cells

  • spread(value, cells)

    Increments or decrements an array of cells proportionally to each other

  • data.cells

    This in an object that contains pure copies of the cell helper functions that return cells instead of cell values. These should be used for getting references to cells to pass to setter helper functions.

Other Helpers

  • meta(name)

    Returns the meta property for the given row. For example, if the metadata for my current row is:

    { a: 123, b: 'hello' }
    

    calling meta('a') will return 123 for all cells in that row.

  • preLink()

    Returns a reference to the preLink data returned by the preLink function provided at initialization.