{"_id":"rocambole-linebreak","_rev":"160927","name":"rocambole-linebreak","description":"helpers for rocambole AST line break manipulation","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"millermedeiros","email":""}],"time":{"modified":"2021-06-03T11:40:08.000Z","created":"2015-03-19T16:10:12.207Z","1.0.2":"2016-05-25T06:52:37.161Z","1.0.1":"2015-03-19T16:55:20.198Z","1.0.0":"2015-03-19T16:10:12.207Z"},"users":{},"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://millermedeiros.com"},"repository":{"type":"git","url":"git+https://github.com/millermedeiros/rocambole-linebreak.git"},"versions":{"1.0.2":{"name":"rocambole-linebreak","version":"1.0.2","description":"helpers for rocambole AST line break manipulation","main":"rocambole-linebreak.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/millermedeiros/rocambole-linebreak.git"},"keywords":["rocambole","ast","esformatter","linebreak"],"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-linebreak/issues"},"homepage":"https://github.com/millermedeiros/rocambole-linebreak","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","rocambole-token":"^1.2.1","semver":"^4.3.1"},"gitHead":"ceb20a22cd1021aeb340926a0eb3109423ffccb4","_id":"rocambole-linebreak@1.0.2","_shasum":"03621515b43b4721c97e5a1c1bca5a0366368f2f","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"dist":{"shasum":"03621515b43b4721c97e5a1c1bca5a0366368f2f","size":4806,"noattachment":false,"key":"/rocambole-linebreak/-/rocambole-linebreak-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-linebreak/download/rocambole-linebreak-1.0.2.tgz"},"maintainers":[{"name":"millermedeiros","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/rocambole-linebreak-1.0.2.tgz_1464159154870_0.11867010220885277"},"directories":{},"publish_time":1464159157161,"_cnpm_publish_time":1464159157161,"_hasShrinkwrap":false},"1.0.1":{"name":"rocambole-linebreak","version":"1.0.1","description":"helpers for rocambole AST line break manipulation","main":"rocambole-linebreak.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-linebreak.git"},"keywords":["rocambole","ast","esformatter","linebreak"],"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-linebreak/issues"},"homepage":"https://github.com/millermedeiros/rocambole-linebreak","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","rocambole-token":"^1.2.1","semver":"^4.3.1"},"gitHead":"cada0e477b747f145a06fdb2f58f4dd1b68f17a9","_id":"rocambole-linebreak@1.0.1","_shasum":"63f62b110c1108e7184460f9d2bac31b94c5c3c0","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"63f62b110c1108e7184460f9d2bac31b94c5c3c0","size":4068,"noattachment":false,"key":"/rocambole-linebreak/-/rocambole-linebreak-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-linebreak/download/rocambole-linebreak-1.0.1.tgz"},"directories":{},"publish_time":1426784120198,"_cnpm_publish_time":1426784120198,"_hasShrinkwrap":false},"1.0.0":{"name":"rocambole-linebreak","version":"1.0.0","description":"helpers for rocambole AST line break manipulation","main":"rocambole-linebreak.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-linebreak.git"},"keywords":["rocambole","ast","esformatter","linebreak"],"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-linebreak/issues"},"homepage":"https://github.com/millermedeiros/rocambole-linebreak","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","semver":"^4.3.1"},"gitHead":"27d8f06e76f221eabf776ab69965de10f1cb470e","_id":"rocambole-linebreak@1.0.0","_shasum":"89a21a6afde74346d9fc9fa5d4e6ce26fa9841f5","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"89a21a6afde74346d9fc9fa5d4e6ce26fa9841f5","size":4055,"noattachment":false,"key":"/rocambole-linebreak/-/rocambole-linebreak-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-linebreak/download/rocambole-linebreak-1.0.0.tgz"},"directories":{},"publish_time":1426781412207,"_cnpm_publish_time":1426781412207,"_hasShrinkwrap":false}},"readme":"# rocambole-linebreak\n\nHelpers to manipulate [rocambole](https://github.com/millermedeiros/rocambole)\n`LineBreak` tokens.\n\nUsed mainly by [esformatter](https://github.com/millermedeiros/esformatter/) and its plugins.\n\n## Allowed values\n\n - positive integer (`1` till `99`): \"add or keep `[n]` line breaks\".\n - `-1`: keep original line breaks.\n - `\">2\"`: add linebreaks until it's over `2`.\n - `\">=1\"`: add line breaks until it's equal or greater than `1`.\n - `\"<2\"`: remove linebreaks until it's smaller than `2`.\n - `\"<=1\"`: remove/add line breaks until it's smaller or equal to `1`.\n\n## API\n\n```js\nvar br = require('rocambole-linebreak');\n```\n\n### setOptions(opts)\n\n`setOptions` is just a way to store some constants so later on the\n`limit`/`limitBefore`/`limitAfter` you can reference the values by Id.\n\n```js\nsetOptions({\n  // sets \"value\" used by `LineBreak` tokens (defaults to `\"\\n\"`)\n  value: '\\n',\n\n  // values inside \"before\" are used by `limitBefore`\n  before: {\n    // setting to `0` will remove all line breaks before the token\n    parenthesis: 0\n  },\n\n  // values inside \"after\" are used by `limitAfter`\n  after: {\n    // setting to `1` will add/keep a single `LineBreak` after the token\n    parenthesis: 1\n  }\n});\n```\n\n**Important:** calling this method will override **all** the options.\n\n### limitBefore(token, typeOrValue)\n\nlimits the amount of `LineBreak` before a given token.\n\n```js\n// remove all line breaks before `node.startToken`\nlimitBefore(node.startToken, 0);\n// add/keep 2 line breaks before `node.startToken`\nlimitBefore(node.startToken, 2);\n// add/keep more than 1 line break\nlimitBefore(node.startToken, '>1');\n// keep 2 line breaks or more\nlimitBefore(node.startToken, '>=2');\n// keep less than 3 line breaks\nlimitBefore(node.startToken, '<3');\n// will use value stored on `setOptions` for `before.parenthesis`\nlimitBefore(node.startToken, 'parenthesis');\n// values smaller than zero are ignored (this won't change anything)\nlimitBefore(node.startToken, -1);\n```\n\n### limitAfter(token, typeOrValue)\n\nlimits the amount of `LineBreak` after a given token.\n\n```js\n// remove all line breaks after `node.startToken`\nlimitAfter(node.startToken, 0);\n// add/keep 1 line break after `node.startToken`\nlimitAfter(node.startToken, 1);\n// add/keep more than 1 line break\nlimitAfter(node.startToken, '>1');\n// keep 2 line breaks or more\nlimitAfter(node.startToken, '>=2');\n// keep less than 3 line breaks\nlimitAfter(node.startToken, '<3');\n// will use value stored on `setOptions` for `after.parenthesis`\nlimitAfter(node.startToken, 'parenthesis');\n// values smaller than zero are ignored (this won't change anything)\nlimitAfter(node.startToken, -1);\n```\n\n### limit(token, typeOrValue)\n\nlimits the amount of `LineBreak` around a given token.\n\n```js\n// add/keep 1 line break before and after `node.startToken`\nlimit(node.startToken, 1);\n\n// it's just an alias to\nlimitBefore(node.startToken, 1);\nlimitAfter(node.startToken, 1);\n```\n\n### limitBeforeEndOfFile(ast[, typeOrValue])\n\nlimits the amount of line breaks at the end of the AST.\n\n```js\n// at least one line break at the end of the file\nlimitBeforeEndOfFile(ast, 1);\n// if you don't pass the `typeOrValue` it will use \"EndOfFile\" as the type\nlimitBeforeEndOfFile(ast);\n```\n\n### expectedBefore(type)\n\nreads value stored during `setOptions` for a given `type`, or returns `-1` if\nnot found.\n\n```js\nassert( expectedBefore('parenthesis') === 0 );\n```\n\n### expectedAfter(type)\n\nreads value stored during `setOptions` for a given `type`, or returns `-1` if\nnot found.\n\n```js\nassert( expectedAfter('parenthesis') === 1 );\n```\n\n## Debug\n\nThis module uses [debug](https://www.npmjs.com/package/debug) internally. To\nmake it easier to identify what is wrong we sometimes run the esformatter tests\nwith a `DEBUG` flag, like:\n\n```sh\nDEBUG=rocambole:br:* npm test\n```\n\n## License\n\nReleased under the MIT License\n\n","_attachments":{},"homepage":"https://github.com/millermedeiros/rocambole-linebreak","bugs":{"url":"https://github.com/millermedeiros/rocambole-linebreak/issues"},"license":"MIT"}