# wide-align

> A wide-character aware text alignment function for use on the console or with fixed width fonts.

Latest version **1.1.5** (published 2021-10-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install wide-align
pnpm add wide-align
yarn add wide-align
bun add wide-align
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2021-10-15 |
| First published | 2015-12-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Rebecca Turner |
| Maintainers | iarna |
| Keywords | wide, double, unicode, cjkv, pad, align |

## Links

- npm: https://www.npmjs.com/package/wide-align
- Repository: https://github.com/iarna/wide-align
- Homepage: https://github.com/iarna/wide-align#readme
- Issues: https://github.com/iarna/wide-align/issues
- npm.io page: https://npm.io/package/wide-align

## Dependencies (1)

- [string-width](https://npm.io/package/string-width.md) ^1.0.2 || 2 || 3 || 4

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2021-10-15
- 1.1.3 — 2018-05-24
- 1.1.2 — 2017-05-11
- 1.1.1 — 2017-05-10
- 1.1.0 — 2016-01-08
- 1.0.2 — 2015-12-31
- 1.0.1 — 2015-12-16
- 1.0.0 — 2015-12-16

## README

wide-align
----------

A wide-character aware text alignment function for use in terminals / on the
console.

### Usage

```
var align = require('wide-align')

// Note that if you view this on a unicode console, all of the slashes are
// aligned. This is because on a console, all narrow characters are
// an en wide and all wide characters are an em. In browsers, this isn't
// held to and wide characters like "古" can be less than two narrow
// characters even with a fixed width font.

console.log(align.center('abc', 10))     // '   abc    '
console.log(align.center('古古古', 10))  // '  古古古  '
console.log(align.left('abc', 10))       // 'abc       '
console.log(align.left('古古古', 10))    // '古古古    '
console.log(align.right('abc', 10))      // '       abc'
console.log(align.right('古古古', 10))   // '    古古古'
```

### Functions

#### `align.center(str, length)` → `str`

Returns *str* with spaces added to both sides such that that it is *length*
chars long and centered in the spaces.

#### `align.left(str, length)` → `str`

Returns *str* with spaces to the right such that it is *length* chars long.

### `align.right(str, length)` → `str`

Returns *str* with spaces to the left such that it is *length* chars long.

### Origins

These functions were originally taken from 
[cliui](https://npmjs.com/package/cliui). Changes include switching to the
MUCH faster pad generation function from
[lodash](https://npmjs.com/package/lodash), making center alignment pad
both sides and adding left alignment.

---
_Source: https://npm.io/package/wide-align · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
