Open km19809 opened 2 years ago
will:
var result = {chars: []};
fix the issue?
Do you have reproduction that can be added to the unit tests?
TypeError: Cannot read properties of undefined (reading 'length') at http://127.0.0.1:5500/figlet.js:719:37
let msg = "Jonathan";
figlet(msg, {
font: "sam3kr",
horizontalLayout: 'default',
verticalLayout: "universal smushing",
width: 8,
whitespaceBreak: true
}, function (err, text) {
//my callback
});
With a width under 15, it throws an error like above.
But with a width of 15, it works!
It seems that a width narrower than the font's width makes the error.
My font, "sam3kr"s maximum width is 14.
I cannot find the exact program flow yet.
It would be great if appropriate error message to the user. ex) Invalid input: A width must be larger than the font's width
@patorjk Just found this issue again, in my browser history. I will try to check why the error happen. If it's my feature I will check what I can do to fix it.
But there is a need for decision, I don't remember what old code did. What the code should do:
I myself think (when I use the code) that it should return empty string or throw an error. I can use one or the other in my code. I prefer empty string so I can just wrap with try..catch the return empty string on error.
The empty string solution sounds good to me.
@Lev-Shapiro did you delete your comment?
Yes, I don't know if you still have that problem, for now I'm working on another feature in this repo. If you still have this problem - tell me, so I'd know it's status because 2 years it's quite a long peiod any many stuff could already change
I found the same issue(#73), but it is closed.
I examined the code, then found a few things.
generateFigTextLines
,nextFigChars.chars
becomes undefined; It is because ofbreakWord
.nextFigChars.chars
is undefined,joinFigArray
throws an Error.The first thing is a more significant problem. The code looks like this:
The return value,
result
, is sometimes not fully initialized.