UNPKG

@davidosborn/crypto-tax-calculator

Version:

A tool to calculate the capital gains of cryptocurrency assets for Canadian taxes

25 lines (21 loc) 565 B
'use strict' import fromEntries from 'fromentries' import fs from 'fs' /** * Loads the historical data from a directory. * @param {string} path The directory. * @returns {object.<string, array>} The historical data, indexed by asset pair. */ function loadHistory(path) { return fromEntries(fs.readdirSync(path) .filter(function(file) { return /[A-Za-z]+-[A-Za-z]+\.json/.test(file) }) .map(function(file) { return [ file.split('.')[0].toUpperCase(), JSON.parse(fs.readFileSync(path + '/' + file)) ] })) } export default loadHistory