camelcase npm module - Possible code improvement
kalmanh opened this issue · 1 comments
kalmanh commented
Take a look at camelcase
You can then shorten your mapHeaders
to just this below
function mapHeaders({header, index}) {
const neededColumns = [
'Description', 'Date Acquired', 'Date Sold', 'Gross Proceeds',
'Cost or Other Basis', 'Reporting Category', 'Wash Sale Loss Disallowed',
'Federal Income Tax Withheld'
];
return neededColumns.includes(header) ? camelCase(header) : null;
}
dguo commented
I considered doing that when I wrote it, but I wanted to specify the columns anyway to be explicit about which ones would be available to the program. Once I did that, adding another line for each one for the case conversion was such a small thing that it didn't seem worth it to add another dependency.
Thanks for the suggestion though!