datapipe
dataPipe - is a fluent data Api to manipulate, transform and process data in JavaScript
Alternatively you can call each function separately. The following code returns the same results
#
DataPipe Initialization#
dataPipeCreates new data pipe object initialized with values. Returns continuous DataPipe object
#
fromCsvParses CSV string and load items into DataPipe.
Uses parseCsv. Returns continuous DataPipe object
#
fromTableLoads dataPipe with Table information.
Uses fromTable. Returns continuous DataPipe object
- rowsOrTable a datarows with 2 dimentional arrays or entire table. If you provide rows, then you have to specify fieldNames
- fieldNames fieldNames what correspond to the rows
- fieldDataTypes fieldNames what correspond to the rows
#
DataPipe Transformation functions#
groupByGroups array items based on elementSelector function.
Uses groupBy function and returns continuous DataPipe object
#
pivotReturns a reshaped array based on unique column values.
Uses pivot function and returns continuous DataPipe object
- rowFields row fields (or index fields). It can be one or more field names
- columnField a field which values will be used to create columns
- dataField a dataField which will be aggrated with aggregate function and groupped by rows and columns
- aggFunction an aggregation function. Default value is sum. data field will be aggregated by this function
- columnValues an optional initial column values. Use it to define a set of columns/values you would expect
#
transposeReturns a transposed array, where rows become columns.
Uses transpose function and returns continuous DataPipe object
#
selectCreates new array based on selector.
- elementSelector A Selector function that is invoked per iteration.
Uses select function and returns continuous DataPipe object
#
mapAlias for select and has same usage
#
whereFilters array based on predicate function.
Uses where function and returns continuous DataPipe object
- predicate A predicate function to filter items.
#
filterAlias for where and has same usage
#
flatternReturns a flaterned array.
Uses flattern function and returns continuous DataPipe object
- array The array to flatten recursively.
#
sortA simple sort array function with a convenient interface.
Uses sort function and returns continuous DataPipe object
- fields field names with a sort order.
example
#
leftJoinReturns a joined array with all elements from the left array (leftArray), and the matched elements from the right array (rightArray). The result is NULL from the right side, if there is no match.
Uses leftJoin function and returns continuous DataPipe object
- rightArray array for right side in a join
- leftKey A key from left side array. What can be as a fieldName, multiple fields or key Selector
- rightKey A key from right side array. what can be as a fieldName, multiple fields or key Selector
- resultSelector A callback function that returns result value */
#
innerJoinJoins two arrays together by selecting elements that have matching values in both arrays. If there are elements in any array that do not have matches in other array, these elements will not be shown!
Uses innerJoin function and returns continuous DataPipe object
- leftArray array for left side in a join
- rightArray array for right side in a join
- leftKey A key from left side array. What can be as a fieldName, multiple fields or key Selector
- rightKey A key from right side array. what can be as a fieldName, multiple fields or key Selector
- resultSelector A callback function that returns result value */
#
fullJoinReturns all elements from the left array (leftArray), and all elements from the right array (rightArray). The result is NULL from the right/left side, if there is no match.
Uses fullJoin function and returns continuous DataPipe object
- rightArray array for right side in a join
- leftKey A key from left side array. What can be as a fieldName, multiple fields or key Selector
- rightKey A key from right side array. what can be as a fieldName, multiple fields or key Selector
- resultSelector A callback function that returns result value */
#
mergeMerges elements from two arrays. It appends source element or overrides to target array based on matching keys provided.
Uses merge function and returns continuous DataPipe object
- sourceArray source array
- targetKey tartget key field, arry of fields or field serlector
- sourceKey source key field, arry of fields or field serlector
#
Aggregation and stats functions#
sumSum of items in array.
Uses sum function. This method stops DataPipe's continuity and returns result value
- elementSelector Function invoked per iteration.
#
avgAverage of array items.
Uses avg function. This method stops DataPipe's continuity and returns result value
- elementSelector Function invoked per iteration.
#
averageAlias for avg and has same usage
#
minComputes the minimum value of array.
- elementSelector Function invoked per iteration.
Uses min function. This method stops DataPipe's continuity and returns result value
#
maxComputes the maximum value of array.
- elementSelector Function invoked per iteration.
Uses max function. This method stops DataPipe's continuity and returns result value
#
countCount of elements in array with optional predicate.
- predicate Predicate function invoked per iteration.
Uses count function. This method stops DataPipe's continuity and returns result value
#
firstGets first item in array that satisfies optional predicate.
- predicate Predicate function invoked per iteration.
Uses first function. This method stops DataPipe's continuity and returns result value
#
lastGets last item in array that satisfies optional predicate.
- predicate Predicate function invoked per iteration.
Uses last function. This method stops DataPipe's continuity and returns result value
#
countByGets counts map of values returned by elementSelector
.
- elementSelector Function invoked per iteration.
Uses countBy function. This method stops DataPipe's continuity and returns result value
#
meanGet mean of an array.
- field Property name or Selector function invoked per iteration.
Uses mean function. This method stops DataPipe's continuity and returns result value
#
quantileGet quantile of a sorted array.
- field Property name or Selector function invoked per iteration.
- p quantile.
Uses quantile function. This method stops DataPipe's continuity and returns result value
#
varianceGet sample variance of an array.
- field Property name or Selector function invoked per iteration.
Uses variance function. This method stops DataPipe's continuity and returns result value
#
stdevGet the sample standard deviation of an array.
- field Property name or Selector function invoked per iteration.
Uses stdev function. This method stops DataPipe's continuity and returns result value
#
medianGet median of an array.
- field Property name or Selector function invoked per iteration.
Uses median function. This method stops DataPipe's continuity and returns result value
#
DataPipe output#
toArrayReturns a result as an array and stops DataPipe continuity
#
toCsvReturns a result as CSV and stops DataPipe continuity.
It uses toCsv
#
toObjectReturns a result as JS Object and stops DataPipe continuity.
- keyField a key selector represented as a string (field name) or array of stringa (fieldNames) or custom selectors
It uses toObject
#
toTableReturns a result as TableDto and stops DataPipe continuity.
It uses toTable
#
DataType other methods#
tapThis method allows you to examine a a state of the data during pipe execution.