* Adds several `values` to the current line, separated by `separator`. Both values and separator * can also be `Builder` instances for more advanced formatting. * * @param separator * @param values * @param writeItem allow to customize how individual item is written * @returns
(
separator: string | BasicBuilder<ContextType>,
values: T[],
writeItem: (item: T, writer: this) => void = (item, w) => w.write(item),
)
| 44 | * @returns |
| 45 | */ |
| 46 | writeJoined<T extends string | BasicBuilder<ContextType>>( |
| 47 | separator: string | BasicBuilder<ContextType>, |
| 48 | values: T[], |
| 49 | writeItem: (item: T, writer: this) => void = (item, w) => w.write(item), |
| 50 | ): this { |
| 51 | const last = values.length - 1 |
| 52 | for (let i = 0; i < values.length; i++) { |
| 53 | writeItem(values[i], this) |
| 54 | if (i !== last) { |
| 55 | this.write(separator) |
| 56 | } |
| 57 | } |
| 58 | return this |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Adds a string to current line, flushes current line and starts a new line. |
no test coverage detected