# linegauge/wrap

> Every export of linegauge/wrap, with its signature and doc comment: visibleWidth, wrap, wrap, plus 2 types.

Source: https://linegauge.interlace.tools/docs/api/wrap

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->

```ts
import wrap from 'linegauge/wrap';
import { visibleWidth, wrap } from 'linegauge/wrap';
```

## Functions

### default

The default export, declared as `wrap`.

Wrap `string` to `columns`, keeping its ANSI intact and each row self-contained.

```ts
function wrap(string: string, columns: number, options?: WrapOptions): string;
```

| Parameter | Type |
| :-- | :-- |
| `string` | `string` |
| `columns` | `number` |
| `options` (optional) | `WrapOptions` |

**Returns** `string`

### visibleWidth

The visible width of a string, escape sequences ignored.

```ts
function visibleWidth(string: string): number;
```

| Parameter | Type |
| :-- | :-- |
| `string` | `string` |

**Returns** `number`

### wrap

Wrap `string` to `columns`, keeping its ANSI intact and each row self-contained.

```ts
function wrap(string: string, columns: number, options?: WrapOptions): string;
```

| Parameter | Type |
| :-- | :-- |
| `string` | `string` |
| `columns` | `number` |
| `options` (optional) | `WrapOptions` |

**Returns** `string`

## Interfaces

### Options

```ts
interface WrapOptions {
    /** Trim leading and trailing whitespace from each row. Default true. */
    trim?: boolean;
    /** Break a word longer than `columns` rather than let it overflow. Default false. */
    hard?: boolean;
    /** Break on any character rather than at word boundaries. Default true. */
    wordWrap?: boolean;
}
```

### WrapOptions

```ts
interface WrapOptions {
    /** Trim leading and trailing whitespace from each row. Default true. */
    trim?: boolean;
    /** Break a word longer than `columns` rather than let it overflow. Default false. */
    hard?: boolean;
    /** Break on any character rather than at word boundaries. Default true. */
    wordWrap?: boolean;
}
```
