Class: Data

Data(storage)

Handles all operations on the data.

Constructor

new Data(storage)

Parameters:
Name Type Description
storage Storage Storage object.
Source:

Methods

getData(fileContents, quest) → {array}

Returns data from an array, filtered by a given quest.
Parameters:
Name Type Description
fileContents array The contents of the array to be filtered.
quest object Contains a connector (or/and) and an array of parameters to filter objects. Example: quest = { connector: 'or', params: [['type', 'earning'], ['budget', 'checking account']] }
Source:
Returns:
All the data which match the quest, in form of an array containing objects.
Type
array

getDataReduce(fileContents, quest, connectFn) → {array}

Does the actual filtering for the getData function.
Parameters:
Name Type Description
fileContents array The content to be filtered.
quest object Specifies how to filter the data.
connectFn function Specifies the connector in the reduce function call. There are two cases: 1. connector: 'or' => connectFn = (a, b) => a || b 2. connector: 'and' => connectFn = (a, b) => a && b
Source:
Returns:
All data which match the quest.
Type
array

joinData(indices, data) → {object}

Joins entries to one entry (just for a nicer display style, the storage remains unchanged).
Parameters:
Name Type Description
indices array The indices we want to join (this array must not be empty).
data object Data object which contains the entries.
Source:
Returns:
The data with joined entries.
Type
object

mergeData(data)

Displays partitioned entries as one entry. This is only necessary for earnings, since spendings cannot be partitioned.
Parameters:
Name Type Description
data array An array containing the merged data.
Source:

sortData(data) → {array}

Sorts data by date (oldest first). Note that each entry has a unique date.
Parameters:
Name Type Description
data array The data we want to sort (in form of an array of objects).
Source:
Returns:
The sorted data.
Type
array