Closed medusalix closed 5 years ago
I added some tests for it, although I'm not quite sure how to use module.exports correctly to export the parseOutput function for testing only.
if (process.env.NODE_ENV === 'test') {
module.exports._parseOutput = parseOutput;
}
(AVA sets this environment variable)
The algorithm using the while loop can surely be improved too. Open for suggestions 😃.
I don't really have any suggestions... I guess the while-loop approach is fine as long as you add a lot of tests to cover the behavior and edge-cases.
Would be good to add some inline code comments to explain your algorithm/approach.
Would be good to add some inline code comments to explain your algorithm/approach.
I simplified the algorithm quite a bit and added some comments to explain the regex.
I don't really have any suggestions... I guess the while-loop approach is fine as long as you add a lot of tests to cover the behavior and edge-cases.
I'm not sure what to test for, apart from the usual output that df
produces. My algorithm relies on the columns being in a certain order (Not sure if that is guaranteed across implementations of df
). Feeding malformed input to the regex obivously produces incorrect results.
Parses the table by calculating the boundaries of its columns. I added some tests for it, although I'm not quite sure how to use
module.exports
correctly to export theparseOutput
function for testing only. The algorithm using thewhile
loop can surely be improved too. Open for suggestions 😃.Fixes #5