Functions for processing design specifications. In particular, it can take concise design specifications and expand them into a long table of factor values.
Members
-
<inner, constant> actionHandlers :Object
-
If an action handler return 'undefined', it means that the handler took care of the action already.
Type:
- Object
Methods
-
<static> calculate()
-
Calculate
expr
using variables inrow
, with optionalaction
object specifyingunits
and/ordecimals
-
<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
[{}]
) -
<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
-
<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
-
<static> flattenArrayM(rows)
-
Is like _.flattenDeep, but it mutates the array in-place.
Parameters:
Name Type Description rows
array array to flatten
-
<static> flattenDesign(design)
-
Turn a design specification into a design table.
Parameters:
Name Type Description design
object the design specification.
-
<static> printMarkdown(rows)
-
Print a markdown pipe table
Parameters:
Name Type Description rows
array array of rows
-
<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
-
<static> printTAB(rows)
-
Print a TAB-formatted representation of the table
Parameters:
Name Type Description rows
array array of rows
-
<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
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.
-
<inner> expandRowsByObject()
-
expandRowsByObject: for each key/value pair, call expandRowsByNamedValue
-
<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
Returns:
filtered table
- Type
- array