{"id":13527344,"url":"https://github.com/nexdrew/ansi-align","last_synced_at":"2025-05-09T00:07:35.590Z","repository":{"id":48309191,"uuid":"57453130","full_name":"nexdrew/ansi-align","owner":"nexdrew","description":":abcd: align-text with ANSI support for CLIs","archived":false,"fork":false,"pushed_at":"2021-09-27T11:53:09.000Z","size":48,"stargazers_count":23,"open_issues_count":15,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-09T00:07:26.365Z","etag":null,"topics":["alignment","ansi-align","ansi-support","center-alignment","cli","padding"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nexdrew.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-30T17:08:04.000Z","updated_at":"2024-12-03T01:27:37.000Z","dependencies_parsed_at":"2022-08-27T05:01:49.023Z","dependency_job_id":null,"html_url":"https://github.com/nexdrew/ansi-align","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexdrew%2Fansi-align","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexdrew%2Fansi-align/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexdrew%2Fansi-align/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexdrew%2Fansi-align/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nexdrew","download_url":"https://codeload.github.com/nexdrew/ansi-align/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166520,"owners_count":21864482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","ansi-align","ansi-support","center-alignment","cli","padding"],"created_at":"2024-08-01T06:01:46.130Z","updated_at":"2025-05-09T00:07:35.546Z","avatar_url":"https://github.com/nexdrew.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# ansi-align\n\n\u003e align-text with ANSI support for CLIs\n\n[![Build Status](https://travis-ci.org/nexdrew/ansi-align.svg?branch=master)](https://travis-ci.org/nexdrew/ansi-align)\n[![Coverage Status](https://coveralls.io/repos/github/nexdrew/ansi-align/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/ansi-align?branch=master)\n[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)\n[![Greenkeeper badge](https://badges.greenkeeper.io/nexdrew/ansi-align.svg)](https://greenkeeper.io/)\n\nEasily center- or right- align a block of text, carefully ignoring ANSI escape codes.\n\nE.g. turn this:\n\n\u003cimg width=\"281\" alt=\"ansi text block no alignment :(\" src=\"https://cloud.githubusercontent.com/assets/1929625/14937509/7c3076dc-0ed7-11e6-8c16-4f6a4ccc8346.png\"\u003e\n\nInto this:\n\n\u003cimg width=\"278\" alt=\"ansi text block center aligned!\" src=\"https://cloud.githubusercontent.com/assets/1929625/14937510/7c3ca0b0-0ed7-11e6-8f0a-541ca39b6e0a.png\"\u003e\n\n## Install\n\n```sh\nnpm install --save ansi-align\n```\n\n```js\nvar ansiAlign = require('ansi-align')\n```\n\n## API\n\n### `ansiAlign(text, [opts])`\n\nAlign the given text per the line with the greatest [`string-width`](https://github.com/sindresorhus/string-width), returning a new string (or array).\n\n#### Arguments\n\n- `text`: required, string or array\n\n    The text to align. If a string is given, it will be split using either the `opts.split` value or `'\\n'` by default. If an array is given, a different array of modified strings will be returned.\n\n- `opts`: optional, object\n\n    Options to change behavior, see below.\n\n#### Options\n\n- `opts.align`: string, default `'center'`\n\n   The alignment mode. Use `'center'` for center-alignment, `'right'` for right-alignment, or `'left'` for left-alignment. Note that the given `text` is assumed to be left-aligned already, so specifying `align: 'left'` just returns the `text` as is (no-op).\n\n- `opts.split`: string or RegExp, default `'\\n'`\n\n    The separator to use when splitting the text. Only used if text is given as a string.\n\n- `opts.pad`: string, default `' '`\n\n    The value used to left-pad (prepend to) lines of lesser width. Will be repeated as necessary to adjust alignment to the line with the greatest width.\n\n### `ansiAlign.center(text)`\n\nAlias for `ansiAlign(text, { align: 'center' })`.\n\n### `ansiAlign.right(text)`\n\nAlias for `ansiAlign(text, { align: 'right' })`.\n\n### `ansiAlign.left(text)`\n\nAlias for `ansiAlign(text, { align: 'left' })`, which is a no-op.\n\n## Similar Packages\n\n- [`center-align`](https://github.com/jonschlinkert/center-align): Very close to this package, except it doesn't support ANSI codes.\n- [`left-pad`](https://github.com/camwest/left-pad): Great for left-padding but does not support center alignment or ANSI codes.\n- Pretty much anything by the [chalk](https://github.com/chalk) team\n\n## License\n\nISC © Contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexdrew%2Fansi-align","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexdrew%2Fansi-align","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexdrew%2Fansi-align/lists"}