{"id":13547737,"url":"https://github.com/chalk/wrap-ansi","last_synced_at":"2025-04-08T09:09:05.235Z","repository":{"id":36747061,"uuid":"41053676","full_name":"chalk/wrap-ansi","owner":"chalk","description":"Wordwrap a string with ANSI escape codes","archived":false,"fork":false,"pushed_at":"2023-10-28T17:40:36.000Z","size":87,"stargazers_count":124,"open_issues_count":5,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-31T16:39:15.846Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chalk.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sindresorhus","Qix-"],"tidelift":"npm/wrap-ansi"}},"created_at":"2015-08-19T18:53:44.000Z","updated_at":"2025-03-26T06:58:45.000Z","dependencies_parsed_at":"2024-06-18T12:27:11.222Z","dependency_job_id":null,"html_url":"https://github.com/chalk/wrap-ansi","commit_stats":{"total_commits":70,"total_committers":11,"mean_commits":6.363636363636363,"dds":"0.37142857142857144","last_synced_commit":"163b878a6eb5d8c32b7bbea65036eeadc0e4def9"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fwrap-ansi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fwrap-ansi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fwrap-ansi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chalk%2Fwrap-ansi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chalk","download_url":"https://codeload.github.com/chalk/wrap-ansi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246606560,"owners_count":20804427,"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":[],"created_at":"2024-08-01T12:01:00.339Z","updated_at":"2025-04-01T08:28:50.572Z","avatar_url":"https://github.com/chalk.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://github.com/sponsors/Qix-","https://tidelift.com/funding/github/npm/wrap-ansi"],"categories":["JavaScript"],"sub_categories":[],"readme":"# wrap-ansi\n\n\u003e Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)\n\n## Install\n\n```sh\nnpm install wrap-ansi\n```\n\n## Usage\n\n```js\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nconst input = 'The quick brown ' + chalk.red('fox jumped over ') +\n\t'the lazy ' + chalk.green('dog and then ran away with the unicorn.');\n\nconsole.log(wrapAnsi(input, 20));\n```\n\n\u003cimg width=\"331\" src=\"screenshot.png\"\u003e\n\n## API\n\n### wrapAnsi(string, columns, options?)\n\nWrap words to the specified column width.\n\n#### string\n\nType: `string`\n\nA string with ANSI escape codes, like one styled by [`chalk`](https://github.com/chalk/chalk).\n\nNewline characters will be normalized to `\\n`.\n\n#### columns\n\nType: `number`\n\nThe number of columns to wrap the text to.\n\n#### options\n\nType: `object`\n\n##### hard\n\nType: `boolean`\\\nDefault: `false`\n\nBy default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.\n\n##### wordWrap\n\nType: `boolean`\\\nDefault: `true`\n\nBy default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.\n\n##### trim\n\nType: `boolean`\\\nDefault: `true`\n\nWhitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.\n\n## Related\n\n- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes\n- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal\n- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right\n- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchalk%2Fwrap-ansi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchalk%2Fwrap-ansi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchalk%2Fwrap-ansi/lists"}