const IGNORE_GROUP_IN_BALANCE = '-'; function getValue(line) { const blockType = getBlockType(line); if (![blockTypes.EARNING, blockTypes.EXPENSE].includes(blockType)) { throw Error('Line does not have value format: ' + line); } const parts = line.trim().split(' '); if (parts.length < 2) { throw Error('Line not in right format: ' + line); } const value = parts[1]; if (isNaN(value)) { throw Error('Wrong value to line: ' + line); } const num = Number(value); return blockType === blockTypes.EARNING ? num : num * -1; } module.exports.getValue = getValue; function ignoreGroupInBalance(groupLine) { const blockType = getBlockType(groupLine); if (blockType !== blockTypes.GROUP) { throw Error('Line is not a group'); } return groupLine[1] === IGNORE_GROUP_IN_BALANCE; } module.exports.ignoreGroupInBalance = ignoreGroupInBalance;