{"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","tarball":"http://registry-npm.ywwl.com/fixed-width-string/download/fixed-width-string-1.0.0.tgz","integrity":"sha512-rEwYW25brnK9DoUVEZ9a1FQWyHXmLWJlUyW0uSIqwWRWglhjeoOXmLl8brB9PTE79wxijuxvuVF+lMTeFJ4BLw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA7j+ryxIHHaP5sNFfBK3eVtNUH79AvD2+Uyr11ipuNmAiEAu93Nj5pPYEe1v3VR8rgA+jD3MxX9f00FzZwfXqf7NKI="}],"size":2736,"noattachment":false,"key":"/fixed-width-string/-/fixed-width-string-1.0.0.tgz"},"directories":{},"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":1441236168381,"_cnpm_publish_time":1441236168381,"dist-tags":{"latest":"2.0.0"}}