From 8227eb4e33bd48992b76aa66a7344bd674cd1385 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Fri, 20 Mar 2026 09:26:33 -0400 Subject: [PATCH] fix: handle undefined head option in toString() When the Table constructor receives head: undefined, toString() crashes with 'Cannot read properties of undefined' because it tries to access .length on the undefined head value. Default to an empty array. Fixes #178 --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index c8d1790..cf4dbd1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -86,7 +86,7 @@ Table.prototype.toString = function (){ var ret = '' , options = this.options , style = options.style - , head = options.head + , head = options.head || [] , chars = options.chars , truncater = options.truncate , colWidths = options.colWidths || new Array(this.head.length)