{"name":"align-text","description":"Align the text in a string.","version":"1.0.2","homepage":"https://github.com/jonschlinkert/align-text","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"contributors":[{"name":"Jon Schlinkert","url":"http://twitter.com/jonschlinkert"},{"name":"Shinnosuke Watanabe","url":"https://shinnn.github.io"}],"repository":{"type":"git","url":"git+https://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":"^5.0.2","longest":"^2.0.1","repeat-string":"^1.6.1"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^3.5.3","word-wrap":"^1.2.3"},"keywords":["align","align-center","alignment","center","center-align","indent","pad","padding","right","right-align","text","typography"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"f43f4732a690cd97e563f842247f227b5182ec77","_id":"align-text@1.0.2","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"},{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"dist":{"integrity":"sha512-uBPDs72zrRTdiTBY0YjBbuBOdXtRyT4qsKPb4bL4O7vH4utz/7KjwTJVsVbdThxMbVzkRGAfk8Ml3xoMvXSEYw==","shasum":"d35cf1c99bc16089af1b2a887683adcb7e6ca68a","tarball":"http://registry-npm.ywwl.com/align-text/download/align-text-1.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCen3nqIDuJgsBeL8FGLZ1ulOxLZxPUxyqGSOI4DJkpuwIgOeHSFzfrxhdZhzedsuYpyxN72n8ogKIOEPcI575e6Js="}],"size":3869,"noattachment":false,"key":"/align-text/-/align-text-1.0.2.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/align-text-1.0.2.tgz_1505302470161_0.43850269448012114"},"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":1505302471117,"_cnpm_publish_time":1505302471117,"dist-tags":{"latest":"1.0.2"}}