{ "_args": [ [ { "raw": "align-text@^0.1.3", "scope": null, "escapedName": "align-text", "name": "align-text", "rawSpec": "^0.1.3", "spec": ">=0.1.3 <0.2.0", "type": "range" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/center-align" ] ], "_from": "align-text@>=0.1.3 <0.2.0", "_id": "align-text@0.1.4", "_inCache": true, "_location": "/align-text", "_nodeVersion": "5.5.0", "_npmOperationalInternal": { "host": "packages-9-west.internal.npmjs.com", "tmp": "tmp/align-text-0.1.4.tgz_1454377856920_0.9624228512402624" }, "_npmUser": { "name": "shinnn", "email": "snnskwtnb@gmail.com" }, "_npmVersion": "3.6.0", "_phantomChildren": {}, "_requested": { "raw": "align-text@^0.1.3", "scope": null, "escapedName": "align-text", "name": "align-text", "rawSpec": "^0.1.3", "spec": ">=0.1.3 <0.2.0", "type": "range" }, "_requiredBy": [ "/center-align", "/right-align" ], "_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "_shasum": "0cd90a561093f35d0a99256c22b7069433fad117", "_shrinkwrap": null, "_spec": "align-text@^0.1.3", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/center-align", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, "bugs": { "url": "https://github.com/jonschlinkert/align-text/issues" }, "dependencies": { "kind-of": "^3.0.2", "longest": "^1.0.1", "repeat-string": "^1.5.2" }, "description": "Align the text in a string.", "devDependencies": { "mocha": "*", "should": "*", "word-wrap": "^1.0.3" }, "directories": {}, "dist": { "shasum": "0cd90a561093f35d0a99256c22b7069433fad117", "tarball": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" }, "engines": { "node": ">=0.10.0" }, "files": [ "index.js" ], "gitHead": "7f08e823a54c6bda319d875895813537a66a4c5e", "homepage": "https://github.com/jonschlinkert/align-text", "keywords": [ "align", "align-center", "alignment", "center", "center-align", "indent", "pad", "padding", "right", "right-align", "text", "typography" ], "license": "MIT", "main": "index.js", "maintainers": [ { "name": "jonschlinkert", "email": "github@sellside.com" }, { "name": "shinnn", "email": "snnskwtnb@gmail.com" } ], "name": "align-text", "optionalDependencies": {}, "readme": "# align-text [![NPM version](https://badge.fury.io/js/align-text.svg)](http://badge.fury.io/js/align-text) [![Build Status](https://travis-ci.org/jonschlinkert/align-text.svg)](https://travis-ci.org/jonschlinkert/align-text)\n\n> Align the text in a string.\n\n**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)](./example.js)\n\nVisit [the example](./example.js) to see how this works.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i align-text --save\n```\n\n## Usage\n\n```js\nvar align = require('align-text');\nalign(text, callback_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* `callback|integer`: if an integer, the text will be indented by that amount. If a function, it must return 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```\n\nTo:\n\n```\n abc\n abc\n abc\n```\n\n## callback\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\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```\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```\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## Related projects\n\n* [center-align](https://github.com/jonschlinkert/center-align): Center-align the text in a string.\n* [justify](https://github.com/bahamas10/node-justify): Left or right (or both) justify text using a custom width and character\n* [longest](https://github.com/jonschlinkert/longest): Get the longest item in an array.\n* [right-align](https://github.com/jonschlinkert/right-align): Right-align the text in a string.\n* [repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string.\n* [word-wrap](https://github.com/jonschlinkert/word-wrap): Wrap words to a specified length.\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/align-text/issues/new)\n\n## Author\n\n**Jon Schlinkert**\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 09, 2015._\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/jonschlinkert/align-text.git" }, "scripts": { "test": "mocha" }, "version": "0.1.4" }