All files / src/modules/implementations/commands/list-definitions/raw accounts.js

100% Statements 26/26
95.23% Branches 20/21
100% Functions 7/7
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2740x 40x 40x 768x 18x 768x 768x 2x 2x 4x 4x 4x 4x 4x 2x 768x 768x 7x 7x 1x 1x 1x 1x 1x 768x 40x  
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = () => ({
    prepareOutput(rows, { details }) {
        return details ? rows : rows.map(({ account }) => account);
    },
    formatCsv(rows, { details }, { csvField }) {
        const lines = [details ? 'account,comment,transactionCount' : 'account'];
        for (const row of rows) {
            const values = details
                ? [row.account, row.comment ?? '', row.transactionCount]
                : [row];
            lines.push(values.map(csvField).join(','));
        }
        return `${lines.join('\n')}\n`;
    },
    formatText(rows, { details }, { formatTextTable }) {
        if (!details)
            return rows.length === 0 ? '' : `${rows.join('\n')}\n`;
        return formatTextTable(rows, [
            { heading: 'Transactions', value: (row) => row.transactionCount, align: 'right' },
            { heading: 'Account', value: (row) => row.account },
            { heading: 'Comment', value: (row) => row.comment ?? '' },
        ]);
    },
});