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#
dataPipe#
Creates new data pipe object initialized with values. Returns continuous DataPipe object
fromCsv#
Parses CSV string and load items into DataPipe.
Uses parseCsv. Returns continuous DataPipe object
fromTable#
Loads 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#
groupBy#
Groups array items based on elementSelector function.
Uses groupBy function and returns continuous DataPipe object
pivot#
Returns 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
transpose#
Returns a transposed array, where rows become columns.
Uses transpose function and returns continuous DataPipe object
select#
Creates new array based on selector.
- elementSelector A Selector function that is invoked per iteration.
Uses select function and returns continuous DataPipe object
map#
Alias for select and has same usage
where#
Filters array based on predicate function.
Uses where function and returns continuous DataPipe object
- predicate A predicate function to filter items.
filter#
Alias for where and has same usage
flattern#
Returns a flaterned array.
Uses flattern function and returns continuous DataPipe object
- array The array to flatten recursively.
sort#
A simple sort array function with a convenient interface.
Uses sort function and returns continuous DataPipe object
- fields field names with a sort order.
example
leftJoin#
Returns 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 */
innerJoin#
Joins 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 */
fullJoin#
Returns 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 */
merge#
Merges 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#
sum#
Sum of items in array.
Uses sum function. This method stops DataPipe's continuity and returns result value
- elementSelector Function invoked per iteration.
avg#
Average of array items.
Uses avg function. This method stops DataPipe's continuity and returns result value
- elementSelector Function invoked per iteration.
average#
Alias for avg and has same usage
min#
Computes the minimum value of array.
- elementSelector Function invoked per iteration.
Uses min function. This method stops DataPipe's continuity and returns result value
max#
Computes the maximum value of array.
- elementSelector Function invoked per iteration.
Uses max function. This method stops DataPipe's continuity and returns result value
count#
Count 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
first#
Gets 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
last#
Gets 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
countBy#
Gets 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
mean#
Get 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
quantile#
Get 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
variance#
Get 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
stdev#
Get 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
median#
Get 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#
toArray#
Returns a result as an array and stops DataPipe continuity
toCsv#
Returns a result as CSV and stops DataPipe continuity.
It uses toCsv
toObject#
Returns 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
toTable#
Returns a result as TableDto and stops DataPipe continuity.
It uses toTable
DataType other methods#
tap#
This method allows you to examine a a state of the data during pipe execution.