MCPcopy Index your code
hub / github.com/bombshell-dev/clack / wrapWithFormat

Function wrapWithFormat

packages/prompts/src/note.ts:25–35  ·  view source on GitHub ↗
(message: string, width: number, format: FormatFn)

Source from the content-addressed store, hash-verified

23const defaultNoteFormatter = (line: string): string => line;
24
25const wrapWithFormat = (message: string, width: number, format: FormatFn): string => {
26 const opts: WrapAnsiOptions = {
27 hard: true,
28 trim: false,
29 };
30 const wrapMsg = wrapAnsi(message, width, opts).split('\n');
31 const maxWidthNormal = wrapMsg.reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0);
32 const maxWidthFormat = wrapMsg.map(format).reduce((sum, ln) => Math.max(stringWidth(ln), sum), 0);
33 const wrapWidth = width - (maxWidthFormat - maxWidthNormal);
34 return wrapAnsi(message, wrapWidth, opts);
35};
36
37export const note = (message = '', title = '', opts?: NoteOptions) => {
38 const output: Writable = opts?.output ?? process.stdout;

Callers 1

noteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected