The code looks great but here are a few changes that might be helpful. I literally made 'newLine' and 'indentPattern' private, since they don't need to be accessed from outside the class literally. However, I added a return statement to the 'format' method to return the formatted input text with existing trailing white spaces removed. It might not be necessary, but I used the nullish coalescing operator ('??') instead of the 'typeof' check to set the default value for 'insertSpaces'.
The code looks great but here are a few changes that might be helpful. I literally made 'newLine' and 'indentPattern' private, since they don't need to be accessed from outside the class literally. However, I added a return statement to the 'format' method to return the formatted input text with existing trailing white spaces removed. It might not be necessary, but I used the nullish coalescing operator ('??') instead of the 'typeof' check to set the default value for 'insertSpaces'.