{"name":"align-text","description":"Align the text in a string.","version":"0.1.3","homepage":"https://github.com/jonschlinkert/align-text","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/align-text.git"},"bugs":{"url":"https://github.com/jonschlinkert/align-text/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"kind-of":"^2.0.0","longest":"^1.0.1","repeat-string":"^1.5.2"},"devDependencies":{"mocha":"*","should":"*","word-wrap":"^1.0.3"},"keywords":["align","align-center","alignment","center","center-align","indent","pad","padding","right","right-align","text","typography"],"gitHead":"11c2e834ff2c63f9844bddf189fea5cab921e44d","_id":"align-text@0.1.3","_shasum":"72db3983872eec2313919c9426a993a41afe93f7","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"72db3983872eec2313919c9426a993a41afe93f7","tarball":"http://registry-npm.ywwl.com/align-text/download/align-text-0.1.3.tgz","integrity":"sha512-rZiwWVUdr4219op+UUctVonyJSrnX4urbisutYjTiaddL2ZLWrt8uEskJt0Q/lCS6ZP9Fzx9bEjGiZHGH3bqrw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5Sf098i8tJGkYG6QHJqYiaHpFlQ57vPntFKt+so/V7wIhAI8syKmV7eTb2iQqSHnzVufOg/eZ0NrMF7pz+V86bX23"}],"size":3565,"noattachment":false,"key":"/align-text/-/align-text-0.1.3.tgz"},"directories":{},"readme":"# align-text [![NPM version](https://img.shields.io/npm/v/align-text.svg?style=flat)](https://www.npmjs.com/package/align-text) [![NPM monthly downloads](https://img.shields.io/npm/dm/align-text.svg?style=flat)](https://npmjs.org/package/align-text) [![NPM total downloads](https://img.shields.io/npm/dt/align-text.svg?style=flat)](https://npmjs.org/package/align-text) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/align-text.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/align-text)\n\n> Align the text in a string.\n\nFollow this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), for updates on this project and others.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save align-text\n```\n\n## Usage\n\n```js\nvar align = require('align-text');\n\nalign(text, function_or_integer);\n```\n\n**Params**\n\n* `text` can be a **string or array**. If a string is passed, a string will be returned. If an array is passed, an array will be returned.\n* `function|integer`: if an integer, the text will be indented by that amount. If a transform function is passed, it must return an object with an `integer` property or an integer representing the amount of leading indentation to use as `align` loops over each line.\n\n**Example**\n\n```js\nalign(text, 4);\n```\n\nWould align:\n\n```\nabc\nabc\nabc\n```\nTo:\n\n```\n    abc\n    abc\n    abc\n```\n\n## Transform function\n\n### params\n\nThe callback is used to determine the indentation of each line and gets the following params:\n\n* `len` the length of the \"current\" line\n* `longest` the length of the longest line\n* `line` the current line (string) being aligned\n* `lines` the array of all lines\n\n### return\n\nThe callback may return:\n\n* an integer that represents the number of spaces to use for padding,\n* or an object with the following properties:\n  - `indent`: **{Number}** the amount of indentation to use. Default is `0` when an object is returned.\n  - `character`: **{String}** the character to use for indentation. Default is `''` (empty string) when an object is returned.\n  - `prefix`: **{String}** leading characters to use at the beginning of each line. `''` (empty string) when an object is returned.\n\n**Integer example:**\n\n```js\n// calculate half the difference between the length\n// of the current line and the longest line\nfunction centerAlign(len, longest, line, lines) {\n  return Math.floor((longest - len) / 2);\n}\n```\n\n**Object example:**\n\n```js\nfunction centerAlign(len, longest, line, lines) {\n  return {\n    character: '\\t',\n    indent: Math.floor((longest - len) / 2),\n    prefix: '~ ',\n  }\n}\n```\n\n## Usage examples\n\nAlign text values in an array:\n\n```js\nalign([1, 2, 3, 100]);\n//=> ['  1', '  2', '  3', '100']\n```\n\nOr [do stuff like this](./example.js):\n\n![screen shot 2015-06-09 at 2 08 34 am](https://cloud.githubusercontent.com/assets/383994/8051597/7b716fbc-0e4c-11e5-9aef-4493fd22db58.png)\n\nVisit [the example](./example.js) to see how this works.\n\n### Center align\n\nUsing the `centerAlign` function from above:\n\n```js\nalign(text, centerAlign);\n```\n\nWould align this text:\n\n```js\nLorem ipsum dolor sit amet\nconsectetur adipiscin\nelit, sed do eiusmod tempor incididun\nut labore et dolor\nmagna aliqua. Ut enim ad mini\nveniam, quis\n```\n\nResulting in this:\n\n```\n     Lorem ipsum dolor sit amet,\n        consectetur adipiscing\nelit, sed do eiusmod tempor incididunt\n         ut labore et dolore\n    magna aliqua. Ut enim ad minim\n             veniam, quis\n```\n\n**Customize**\n\nIf you wanted to add more padding on the left, just pass the number in the callback.\n\nFor example, to add 4 spaces before every line:\n\n```js\nfunction centerAlign(len, longest, line, lines) {\n  return 4 + Math.floor((longest - len) / 2);\n}\n```\n\nWould result in:\n\n```\n         Lorem ipsum dolor sit amet,\n            consectetur adipiscing\n    elit, sed do eiusmod tempor incididunt\n             ut labore et dolore\n        magna aliqua. Ut enim ad minim\n                 veniam, quis\n```\n\n### Bullets\n\n```js\nalign(text, function (len, max, line, lines) {\n  return {prefix: ' - '};\n});\n```\nWould return:\n\n```\n- Lorem ipsum dolor sit amet,\n- consectetur adipiscing\n- elit, sed do eiusmod tempor incididunt\n- ut labore et dolore\n- magna aliqua. Ut enim ad minim\n- veniam, quis\n```\n\n### Different indent character\n\n```js\nalign(text, function (len, max, line, lines) {\n  return { \n    indent: Math.floor((max - len) / 2), \n    character: '~', \n  };\n});\n```\nWould return\n\n```\n~~~~~Lorem ipsum dolor sit amet,\n~~~~~~~~consectetur adipiscing\nelit, sed do eiusmod tempor incididunt\n~~~~~~~~~ut labore et dolore\n~~~~magna aliqua. Ut enim ad minim\n~~~~~~~~~~~~~veniam, quis\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 14 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 2 | [shinnn](https://github.com/shinnn) |\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 13, 2017._","publish_time":1433831100237,"_cnpm_publish_time":1433831100237,"dist-tags":{"latest":"1.0.2"}}