Module: design

Functions for processing design specifications. In particular, it can take concise design specifications and expand them into a long table of factor values.

Source:

Members


<inner, constant> actionHandlers :Object

If an action handler return 'undefined', it means that the handler took care of the action already.

Type:
  • Object
Source:

Methods


<static> calculate()

Calculate expr using variables in row, with optional action object specifying units and/or decimals

Source:

<static> expandConditions(conditions, table0)

If conditions is an array, then each element will be processed individually and then the results will be merged together.

Parameters:
Name Type Description
conditions object | array

an object of conditions or an array of such objects.

table0 array

the initial rows to start expanding conditions on (default [{}])

Source:

<static> expandRowsByNamedValue()

// REQUIRED by: expandRowsByObject expandRowsByNamedValue: TODO: turn the name/value into an action in order to allow for more sophisticated expansion if has star-suffix, call branchRowsByNamedValue else call assignRowsByNamedValue

Source:

<static> flattenArrayAndIndexes(rows, rowIndexes [, otherRowIndexes], rowIndexesOffset)

Is like _.flattenDeep, but only for the given rows, and it mutates both the rows array and rowIndexes array in-place.

Parameters:
Name Type Argument Description
rows array

array to flatten

rowIndexes array

array of row indexes to flatten

otherRowIndexes array <optional>

a second, optional array of row indexes that should have the same modifications made to it as rowIndexes

rowIndexesOffset integer

index in rowIndexes to start at

Source:

<static> flattenArrayM(rows)

Is like _.flattenDeep, but it mutates the array in-place.

Parameters:
Name Type Description
rows array

array to flatten

Source:

<static> flattenDesign(design)

Turn a design specification into a design table.

Parameters:
Name Type Description
design object

the design specification.

Source:

<static> printMarkdown(rows)

Print a markdown pipe table

Parameters:
Name Type Description
rows array

array of rows

Source:

<static> printRows(rows [, hideRedundancies])

Print a text representation of the table

Parameters:
Name Type Argument Description
rows array

array of rows

hideRedundancies Boolean <optional>

suppress printing of values that haven't changed from the previous row

Source:

<static> printTAB(rows)

Print a TAB-formatted representation of the table

Parameters:
Name Type Description
rows array

array of rows

Source:

<static> query_orderBy(rows, rowIndexes, orderBy)

Return an array of rowIndexes which are ordered by the orderBy criteria.

Parameters:
Name Type Description
rows array

a flat array of row objects

rowIndexes array

array of row indexes to consider

orderBy string | array

the column(s) to order by

Source:
Returns:

a sorted ordering of rowIndexes

Type
array

<inner> assertNoDuplicates()

Check whether the same underlying array shows up more than once in otherRowIndexes. This should never be the case, because if we modify one, the "other" will also be modified.

Source:

<inner> expandRowsByObject()

expandRowsByObject: for each key/value pair, call expandRowsByNamedValue

Source:

<inner> filterOnWhereOnce(table, key, x, fn)

Sub-function that filters table on a single criterion.

Parameters:
Name Type Description
table array

table to filter

key string

key of column in table

x any

value to compare to

fn function

comparison function

Source:
Returns:

filtered table

Type
array