Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs';
import { createCanvas } from 'canvas';

const defaultOptions = {
const defaultOptions = Object.freeze({
cellWidth: 100,
cellHeight: 40,
offsetLeft: 8,
Expand All @@ -13,10 +13,10 @@ const defaultOptions = {
paddingVertical: 0,
paddingHorizontal: 0,
backgroundColor: '#ffffff',
};
});

const TableRenderer = (options = {}) => {
const { cellWidth, cellHeight, offsetLeft, offsetTop, spacing, titleSpacing, fontFamily, paddingHorizontal, paddingVertical, backgroundColor } = Object.assign(defaultOptions, options);
const { cellWidth, cellHeight, offsetLeft, offsetTop, spacing, titleSpacing, fontFamily, paddingHorizontal, paddingVertical, backgroundColor } = {...defaultOptions, ...options};

const getTableWidth = (columns) => {
return columns?.reduce((sum, col) => sum + (col === '|' ? 1 : col.width ?? cellWidth), 0) ?? cellWidth;
Expand Down