{"_id":"fixed-width-string","_rev":"3184223","name":"fixed-width-string","description":"Terminal ANSI-aware string fit to fixed width","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"lahmatiy","email":"rdvornov@gmail.com"}],"time":{"modified":"2023-12-06T08:49:47.000Z","created":"2015-09-02T23:22:48.381Z","2.0.0":"2020-05-15T10:46:55.427Z","1.1.0":"2020-01-05T21:37:41.362Z","1.0.0":"2015-09-02T23:22:48.381Z"},"users":{},"author":{"name":"Roman Dvornov","email":"rdvornov@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/lahmatiy/fixed-width-string.git"},"versions":{"2.0.0":{"name":"fixed-width-string","version":"2.0.0","description":"Terminal ANSI-aware string fit to fixed width","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lahmatiy/fixed-width-string.git"},"author":{"name":"Roman Dvornov","email":"rdvornov@gmail.com"},"engines":{"node":">=8.0.0"},"main":"./index.js","keywords":["string","text","padding","truncate","align","ellipsis","width","formatting","terminal","cli","console","ansi","color"],"scripts":{"lint":"eslint *.js","lint-and-test":"npm run lint && npm test","test":"mocha --reporter ${REPORTER:-progress}","coverage":"nyc npm test","travis":"nyc npm run lint-and-test && npm run coveralls","coveralls":"nyc report --reporter=text-lcov | coveralls"},"devDependencies":{"chalk":"^3.0.0","coveralls":"^3.0.11","eslint":"^6.5.1","mocha":"^7.0.0","nyc":"^14.1.0","strip-ansi":"^6.0.0"},"gitHead":"939c601df0d30931f2881871d68a08cadfb90b6a","bugs":{"url":"https://github.com/lahmatiy/fixed-width-string/issues"},"homepage":"https://github.com/lahmatiy/fixed-width-string#readme","_id":"fixed-width-string@2.0.0","_nodeVersion":"8.17.0","_npmVersion":"6.13.7","dist":{"shasum":"c868790d564cafb3cd6dd6cfbed245777fa942a5","size":3390,"noattachment":false,"key":"/fixed-width-string/-/fixed-width-string-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fixed-width-string/download/fixed-width-string-2.0.0.tgz"},"maintainers":[{"name":"lahmatiy","email":"rdvornov@gmail.com"}],"_npmUser":{"name":"lahmatiy","email":"rdvornov@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fixed-width-string_2.0.0_1589539615313_0.31064602175388467"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-21T03:37:49.313Z","publish_time":1589539615427,"_cnpm_publish_time":1589539615427},"1.1.0":{"name":"fixed-width-string","version":"1.1.0","description":"Terminal ANSI-aware string fit to fixed width","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lahmatiy/fixed-width-string.git"},"author":{"name":"Roman Dvornov","email":"rdvornov@gmail.com"},"engines":{"node":">=0.10.0"},"main":"./index.js","keywords":["string","text","padding","truncate","align","ellipsis","width","formatting","terminal","cli","console","ansi","color"],"devDependencies":{"chalk":"^3.0.0","strip-ansi":"^6.0.0","mocha":"^7.0.0"},"scripts":{"test":"mocha"},"gitHead":"0ca34f41338d11802a51b54a283762f8ba722f93","bugs":{"url":"https://github.com/lahmatiy/fixed-width-string/issues"},"homepage":"https://github.com/lahmatiy/fixed-width-string#readme","_id":"fixed-width-string@1.1.0","_nodeVersion":"13.5.0","_npmVersion":"6.13.4","dist":{"shasum":"823ca36d3b55163eccf2cf22f602ac87a811e265","size":3021,"noattachment":false,"key":"/fixed-width-string/-/fixed-width-string-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fixed-width-string/download/fixed-width-string-1.1.0.tgz"},"maintainers":[{"name":"lahmatiy","email":"rdvornov@gmail.com"}],"_npmUser":{"name":"lahmatiy","email":"rdvornov@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fixed-width-string_1.1.0_1578260261219_0.22706347753524714"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-21T03:37:48.434Z","publish_time":1578260261362,"_cnpm_publish_time":1578260261362},"1.0.0":{"name":"fixed-width-string","version":"1.0.0","description":"Terminal ANSI-aware string fit to fixed width","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lahmatiy/fixed-width-string.git"},"author":{"name":"Roman Dvornov","email":"rdvornov@gmail.com"},"engines":{"node":">=0.10.0"},"main":"./index.js","files":["index.js"],"keywords":["string","text","padding","truncate","align","ellipsis","width","formatting","terminal","cli","console","ansi","color"],"devDependencies":{"chalk":"*","strip-ansi":"*","mocha":"*"},"scripts":{"test":"mocha"},"gitHead":"f966d2189e14466b8261a8f7a6b7ba504163630b","bugs":{"url":"https://github.com/lahmatiy/fixed-width-string/issues"},"homepage":"https://github.com/lahmatiy/fixed-width-string#readme","_id":"fixed-width-string@1.0.0","_shasum":"93bdbd03e6915cd265e396a1b7f3cc6b0880324d","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"lahmatiy","email":"rdvornov@gmail.com"},"maintainers":[{"name":"lahmatiy","email":"rdvornov@gmail.com"}],"dist":{"shasum":"93bdbd03e6915cd265e396a1b7f3cc6b0880324d","size":2736,"noattachment":false,"key":"/fixed-width-string/-/fixed-width-string-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fixed-width-string/download/fixed-width-string-1.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-21T03:37:47.569Z","publish_time":1441236168381,"_cnpm_publish_time":1441236168381}},"readme":"[![NPM version](https://img.shields.io/npm/v/fixed-width-string.svg)](https://www.npmjs.com/package/fixed-width-string)\n[![Build Status](https://travis-ci.org/lahmatiy/fixed-width-string.svg?branch=master)](https://travis-ci.org/lahmatiy/fixed-width-string)\n[![Coverage Status](https://coveralls.io/repos/github/lahmatiy/fixed-width-string/badge.svg?branch=master)](https://coveralls.io/github/lahmatiy/fixed-width-string?branch=master)\n\n\nFit a string to the fixed width (length) with aware of [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).\n\nFeatures:\n\n- Works well with strings with ANSI escape codes, i.e strings styled with a lib like [chalk](https://github.com/chalk/chalk)\n- Pad or truncate string if needed\n- Align string\n\n## Install\n\n```\n$ npm install fixed-width-string\n```\n\n## Usage\n\n```js\nvar fixedWidthString = require('fixed-width-string');\n\nconsole.log(fixedWidthString('test', 10));\n// \"test      \"\n\nconsole.log(fixedWidthString('very long string', 10));\n// \"very long…\"\n\nconsole.log(fixedWidthString('very long string', { align: 'right' }));\n// \"…ng string\"\n\nvar chalk = require('chalk');\n\nconsole.log(fixedWidthString(chalk.green('hello') + ' ' + chalk.red('world'), 8));\n// \"\\u001b[32mhello\\u001b[39m \\u001b[31mw…\\u001b[39m\"\n//\n// but in terminal you'll see colored\n// \"hello w…\"\n```\n\n## API\n\n```js\nfixedWidthString(str, width[, options])\n```\n\n### options.padding\n\nString to padding with.\n\nDefault: `' '` (one space)\n\n```js\nconsole.log(fixedWidthString('test', 10));\n// \"test      \"\n\nconsole.log(fixedWidthString('test', 10, { padding: '.' }));\n// \"test......\"\n```\n\n### options.align\n\nSide to align.\n\nValues: `'left'` or `'right'`  \nDefault: `'left'`\n\n```js\nconsole.log(fixedWidthString('test', 10));\n// \"test      \"\n\nconsole.log(fixedWidthString('test', 10, { align: 'right' }));\n// \"      test\"\n```\n\n### options.ellipsis\n\nString to be placed when string is truncating.\n\nDefault: `'…'`\n\n> Note: To omit ellipsis, pass an empty string or falsy value for the option.\n\n```js\nconsole.log(fixedWidthString('hello world', 8));\n// \"hello w…\"\n\nconsole.log(fixedWidthString('hello world', 8, { ellipsis: '~' }));\n// \"hello w~\"\n\nconsole.log(fixedWidthString('hello world', 8, { ellipsis: '...', align: 'right' }));\n// \"...world\"\n\nconsole.log(fixedWidthString('hello world', 8, { ellipsis: false, align: 'right' }));\n// \"lo world\"\n```\n\n### options.truncate\n\nSide should be truncated.\n\nValues: `'left'` or `'right'`  \nDefault: `'right'` when `align: 'left'` or `'left'` when `align: 'right'`\n\n```js\nconsole.log(fixedWidthString('hello world', 8));\n// \"hello w…\"\n\nconsole.log(fixedWidthString('hello world', 8, { truncate: 'left' }));\n// \"…o world\"\n\nconsole.log(fixedWidthString('hello world', 8, { align: 'right' }));\n// \"hello w…\"\n\nconsole.log(fixedWidthString('hello world', 8, { align: 'right', truncate: 'left' }));\n// \"…o world\"\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/lahmatiy/fixed-width-string#readme","bugs":{"url":"https://github.com/lahmatiy/fixed-width-string/issues"},"license":"MIT"}