const main = async () => { const [timePast, timeName, timeApi] = time() const past = moment() .subtract(timePast, timeName) .format('YYYY-MM-DD hh:mm a') const history = interpolateArray(args.maxWidth)(await CryptoCompareAPI. fetchCoinHistory(timeApi, args.coin, currency, timePast)) const value = await CryptoCompareAPI.fetchCoinPrice(args.coin, currency) const baseLegend = `\t ${args.coin} last ${timePast} ${timeName}` const now = `. Now: ${value[currency]} ${currency}` const legend = baseLegend + ` since ${past}` + now const smallLegend = baseLegend + now const fixed = normalize(max(history)) const fixedHist = map(x => x.toFixed(fixed))(history) const padding = pad(2 + max(fixedHist).toString().length)('') print(asciichart.plot(fixedHist, { height: args.maxHeight, padding: padding, format: x => (padding + x.toFixed(fixed)).slice(-padding.length) })) return args.maxWidth < 40 ? false : !args.disableLegend && print(args.maxWidth < 65 ? smallLegend : legend) }
function r(state = initState, action = {}) { const { type, payload /*, meta = {}*/ } = action; switch (type) { case progressTypes.RESET: return { ...state, pos: 0, ...payload, }; case progressTypes.INCREASE: return { ...state, pos: min([state.pos + (payload || state.step), state.max]), }; case progressTypes.DECREASE: return { ...state, pos: max([state.pos - (payload || state.step), state.min]), }; default: return state; } }
function r(state = initState, action = {}) { const { type, payload /*, meta = {}*/ } = action; switch (type) { case progressTypes.RESET: return { ...state, pos: 0, ...payload, }; case progressTypes.INCREASE: return { ...state, pos: min([state.pos + (payload || state.step), state.max]), }; case progressTypes.DECREASE: return { ...state, pos: max([state.pos - (payload || state.step), state.min]), }; default: return state; } }