{"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":{"integrity":"sha512-x0EEj6r54LPjESQpwtU6Dwxk08TSfXZrOGNsaHBOY9RUxepw8JZ8sZtrrvD1zqB3wMi1whvGflOugcSMlRVn4Q==","shasum":"c868790d564cafb3cd6dd6cfbed245777fa942a5","tarball":"http://registry-npm.ywwl.com/fixed-width-string/download/fixed-width-string-2.0.0.tgz","fileCount":6,"unpackedSize":8899,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevnMfCRA9TVsSAnZWagAAa8UP/jmz2KC3ReDqZFf7Af9v\noFkc91qhjeiXfCJszZFFc+V4KzVpbIzRCCtIQ/DMCmwXQ1NU7X7VS6juPL9u\nDq586FioIChHPIshMUZorjEhuRMLX5LaV3tz6apn4PAlwQSxP0C5aBygxx2I\nukrtRkdVAny/UeTo0SwFLZ/mNvzkcAEp/pab44q+arvtIxaeimrSOoCG5hdl\nJbXSry8mRTMqEYVsPQLFX087MwsMn0BKhQcyqiXKVbLBCpVX+MyRR7nU3XkR\nYxXLuhxiJWcXSFjIalUBPZmsVxsAo6QAL8e4362KzGy47t1I+TcIfweGM0oy\nrHqeCslUcN7Y/o43Bs+fMbYb8wcqSzXKTsHg10RQsk+3goiYzeXCgqtGF6MZ\n+7CbZBib+lPqXeYCQ/v4XuQPPOG5myVdfuAQMBux+gX1xOmmfUnxKpsN+nDz\nAlE44eaZyEg3xdbY+PfQ/OdzSeL8/451uohfhDp+T7DeXfCBvXTK4pKYZXJV\nEaH53Em9Zx+AZuMp5ntsN8a6RE8thk4wcbhGGNo4linFa+n67CFd8Ux6A0P7\nWS8wbX6ZFrsbEmox02Y+c2EZC/PVJEaWhL41Zbebc7S4F+xufTX4uiBKRp81\noNZHq6CLMsInpVc+cFfgppKhby6Wu6hr1epU8zzl5nTcmnW0rSn20BTU1nGu\ndEoH\r\n=g/os\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzpW2VV6sQgtHfE0XrHZ+U1IyWTkO9foB6j2eJqAe+4QIhAPpyGOZSSTWQaQevDpZXiX5R7R98HORr1Z7JiNiQhUoY"}],"size":3390,"noattachment":false,"key":"/fixed-width-string/-/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,"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","publish_time":1589539615427,"_cnpm_publish_time":1589539615427,"dist-tags":{"latest":"2.0.0"}}