Namespace: utils

utils

A namespace containing useful utility functions.
Source:

Methods

(static) alignIssuesToCommits(issues, commits) → {Object.<CommitId, IssuesCount>}

Align issues to commits by date
Parameters:
Name Type Description
issues Array.<IssueInfo> The issues to align
commits Array.<CommitInfo> The commits to align the issues to
Source:
Returns:
Type
Object.<CommitId, IssuesCount>

(static) argParse(rawArgs) → {object}

Parses an Array of strings (flags and values) into an object of flag keys, and value values.
Parameters:
Name Type Description
rawArgs Array.<string> the Array of command line arguments to be parsed
Source:
Returns:
the parsed command line arguments. Where each flag (strings beginning with '-' or '--') is a key, and the following strings (until the next flag) are the values. If a flag has no associated value it is simply 'true' (boolean). If it has multiple associated values they will be stored in an Array. If it has only one, it is simply a string.
Type
object

(static) flatten(obj, prefixopt) → {Object}

Flattens a nested object.
Parameters:
Name Type Attributes Default Description
obj Object The object to flatten
prefix string <optional>
'' The prefix for the flattened keys.
Source:
Returns:
- The flattened object.
Type
Object

(static) gen(start, step, stop) → {Array.<T>}

Gen takes in a starting value, a stepper function and a stopper function, and generates an array: [stepper^0(start), ... stepper^n(start) | stop(stepper^n(start)) === true] In other words, an array starting at the starting value, applying the stepper function to create each subsequent value, until the stopper function for that value returns true.
Parameters:
Name Type Description
start T The starting value
step stepperFunction.<T> The stepper funtion
stop stopperFunction.<T> The stopper function
Source:
Returns:
The generated array
Type
Array.<T>

(static) jsonToCsv(objs, headeropt, sepopt, endopt) → {string}

Takes in a list of flat json objects and outputs a CSV string.
Parameters:
Name Type Attributes Default Description
objs Array.<Object> The objects
header Array.<string> <optional>
The header, keys of the first object will be used if none provided.
sep string <optional>
',' The separator for each column.
end string <optional>
'\n' The separator for each row.
Source:
Returns:
- The CSV string
Type
string

(static) pairs(array) → {Array.<Array.<T>>}

Pairs takes in an array and returns and array of consecutive pairs (i.e. pairs([x_0, x_1, ... x_n]) = [[x_0, x_1], [x_1, x_2], ... [x_(n-1), x_n]])
Parameters:
Name Type Description
array Array.<T> The input array
Source:
Returns:
The resulting array of pairs
Type
Array.<Array.<T>>

(static) parseURL(url) → {ProjectInfo}

Parses a GitHub project URL
Parameters:
Name Type Description
url string The GitHub project URL, must contain 'github.com'
Source:
Returns:
The owner and the name of the project
Type
ProjectInfo

(static) rows2points(rows, keyopt, nameColopt, valColopt) → {Array.<Point>}

Transforms a list of row-like objects into a list of point-like objects. Used to format the database output into something to be used by the graph in the front-end
Parameters:
Name Type Attributes Default Description
rows Array.<Row> The rows to be transformed
key keyFunction <optional>
(({commit_id, file_extension}) => commit_id + ":" + file_extension) The function to identify each unique point from a row
nameCol string <optional>
'metric_type' The property of the metric name
valCol string <optional>
'metric_value' The property of the metric value
Source:
Returns:
The Points
Type
Array.<Point>

(static) uniques(duplicates) → {Array.<T>}

Gets values of the list excluding duplicates
Parameters:
Name Type Description
duplicates Array.<T> The list with potential duplicates
Source:
Returns:
- The list with duplicate elements removed
Type
Array.<T>

(static) unwrap(obj, leaf) → {object}

Unwrap takes in an object, and a leaf key and moves the values of the leaf keys up a level in the object tree (i.e. object.sub_level.leaf = object.leaf, for all 'leaf' in 'object')
Parameters:
Name Type Description
obj object The object to unwrap
leaf string The leaf key
Source:
Returns:
The unwrapped object
Type
object

(static) writeToFile(source, filename, optionsopt)

Write an object to a JSON File .
Parameters:
Name Type Attributes Description
source Object | string The Object or string to be written to the file
filename string The filename that will be written to
options WriteToFileOptions <optional>
The writing options
Source:

(static) zip(…arrays) → {Array.<*>}

Zip takes any number of arrays (e.g. xs = [x_0...x_n], ys = [y_0...y_m]) and returns an array where each element is an array of the n^th elements of the input arrays (i.e. zip(xs, ys) = [[x_0, y_0] ... [x_k, y_k] | k = min(n, m)]). Similarly for larger number of input arrays.
Parameters:
Name Type Attributes Description
arrays Array.<*> <repeatable>
The input arrays
Source:
Returns:
zipped - The zipped array
Type
Array.<*>