/ ink / wrapAnsi.ts
wrapAnsi.ts
 1  import wrapAnsiNpm from 'wrap-ansi'
 2  
 3  type WrapAnsiOptions = {
 4    hard?: boolean
 5    wordWrap?: boolean
 6    trim?: boolean
 7  }
 8  
 9  const wrapAnsiBun =
10    typeof Bun !== 'undefined' && typeof Bun.wrapAnsi === 'function'
11      ? Bun.wrapAnsi
12      : null
13  
14  const wrapAnsi: (
15    input: string,
16    columns: number,
17    options?: WrapAnsiOptions,
18  ) => string = wrapAnsiBun ?? wrapAnsiNpm
19  
20  export { wrapAnsi }