{"_id":"rocambole-indent","_rev":"160902","name":"rocambole-indent","description":"helpers for rocambole AST indentation","dist-tags":{"latest":"2.0.4"},"maintainers":[{"name":"millermedeiros","email":""}],"time":{"modified":"2021-06-03T11:40:07.000Z","created":"2015-03-20T05:52:21.073Z","2.0.4":"2015-05-02T20:23:24.359Z","2.0.3":"2015-03-27T19:32:56.292Z","2.0.2":"2015-03-25T22:29:10.719Z","2.0.1":"2015-03-25T20:18:09.960Z","2.0.0":"2015-03-25T20:09:05.067Z","1.1.1":"2015-03-25T20:03:26.468Z","1.1.0":"2015-03-25T19:34:29.482Z","1.0.0":"2015-03-24T15:36:49.634Z","0.2.0":"2015-03-20T19:27:05.966Z","0.1.0":"2015-03-20T05:52:21.073Z"},"users":{},"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"versions":{"2.0.4":{"name":"rocambole-indent","version":"2.0.4","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"disparity":"^2.0.0","rocambole":"^0.5.1"},"gitHead":"c3e41b175da3b964814b0214df96d507e0bd4128","_id":"rocambole-indent@2.0.4","_shasum":"a18a24977ca0400b861daa4631e861dcb52d085c","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"a18a24977ca0400b861daa4631e861dcb52d085c","size":6698,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-2.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-2.0.4.tgz"},"directories":{},"publish_time":1430598204359,"_cnpm_publish_time":1430598204359,"_hasShrinkwrap":false},"2.0.3":{"name":"rocambole-indent","version":"2.0.3","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"ec57530ab421e34ab976ebc4631d4b7167adb370","_id":"rocambole-indent@2.0.3","_shasum":"fb2d257d01a0f6ebd045eb0fd3e42c4f7cac54ce","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"fb2d257d01a0f6ebd045eb0fd3e42c4f7cac54ce","size":6516,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-2.0.3.tgz"},"directories":{},"publish_time":1427484776292,"_cnpm_publish_time":1427484776292,"_hasShrinkwrap":false},"2.0.2":{"name":"rocambole-indent","version":"2.0.2","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"971bf578f8c3b0660bb372abd3912848e39703b5","_id":"rocambole-indent@2.0.2","_shasum":"c0c0292f74c3d94861cdf3ebe55e04a4b1cf24d4","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"c0c0292f74c3d94861cdf3ebe55e04a4b1cf24d4","size":6435,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-2.0.2.tgz"},"directories":{},"publish_time":1427322550719,"_cnpm_publish_time":1427322550719,"_hasShrinkwrap":false},"2.0.1":{"name":"rocambole-indent","version":"2.0.1","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"dd49ba6533e484c51da6526d51b5fd7fd67af4b2","_id":"rocambole-indent@2.0.1","_shasum":"e56420c9d174ca2041340a9c82fff0239963e5d3","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"e56420c9d174ca2041340a9c82fff0239963e5d3","size":5974,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-2.0.1.tgz"},"directories":{},"publish_time":1427314689960,"_cnpm_publish_time":1427314689960,"_hasShrinkwrap":false},"2.0.0":{"name":"rocambole-indent","version":"2.0.0","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"7912d3962d1745b2af4fb3e2a2a13b6f275c7fab","_id":"rocambole-indent@2.0.0","_shasum":"ff3096ee0d67f8517913c7612c4886a3c08926f6","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"ff3096ee0d67f8517913c7612c4886a3c08926f6","size":5903,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-2.0.0.tgz"},"directories":{},"publish_time":1427314145067,"_cnpm_publish_time":1427314145067,"_hasShrinkwrap":false},"1.1.1":{"name":"rocambole-indent","version":"1.1.1","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"df80825c61af62017c42525eaf860c546a948d97","_id":"rocambole-indent@1.1.1","_shasum":"279c949165e4f23cbfc2d9795d4836a8afece7d9","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"279c949165e4f23cbfc2d9795d4836a8afece7d9","size":5626,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-1.1.1.tgz"},"directories":{},"publish_time":1427313806468,"_cnpm_publish_time":1427313806468,"_hasShrinkwrap":false},"1.1.0":{"name":"rocambole-indent","version":"1.1.0","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"node test/runner.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"devDependencies":{"diff":"^1.3.1","rocambole":"^0.5.1"},"gitHead":"53a0240d5b782bb06c564e7ca7cebde8f680273e","_id":"rocambole-indent@1.1.0","_shasum":"4674ed3e43bcecf22be5a82a95ceae67cf3c6c05","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"4674ed3e43bcecf22be5a82a95ceae67cf3c6c05","size":5597,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-1.1.0.tgz"},"directories":{},"publish_time":1427312069482,"_cnpm_publish_time":1427312069482,"_hasShrinkwrap":false},"1.0.0":{"name":"rocambole-indent","version":"1.0.0","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"gitHead":"98637be402a3df7bc462448a68ff53d354388573","_id":"rocambole-indent@1.0.0","_shasum":"1cb8b22c8e0e25d630fbbb0497ad5da1cc57310d","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"1cb8b22c8e0e25d630fbbb0497ad5da1cc57310d","size":4323,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-1.0.0.tgz"},"directories":{},"publish_time":1427211409634,"_cnpm_publish_time":1427211409634,"_hasShrinkwrap":false},"0.2.0":{"name":"rocambole-indent","version":"0.2.0","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"gitHead":"7e129aeb154dfae4fdb38f6d42d4e315b5f3b8ab","_id":"rocambole-indent@0.2.0","_shasum":"a4a48407fad0754b8d37323f08cc380f793488c3","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"a4a48407fad0754b8d37323f08cc380f793488c3","size":3661,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-0.2.0.tgz"},"directories":{},"publish_time":1426879625966,"_cnpm_publish_time":1426879625966,"_hasShrinkwrap":false},"0.1.0":{"name":"rocambole-indent","version":"0.1.0","description":"helpers for rocambole AST indentation","main":"rocambole-indent.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/millermedeiros/rocambole-indent.git"},"keywords":["rocambole","ast","esformatter","indent"],"author":{"name":"Miller Medeiros","email":"http://millermedeiros.com","url":"contact@millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"homepage":"https://github.com/millermedeiros/rocambole-indent","jshintConfig":{"node":true,"eqnull":true},"dependencies":{"debug":"^2.1.3","mout":"^0.11.0","rocambole-token":"^1.2.1"},"gitHead":"aeb39004c627158e5c35c63a73884425aa0a1169","_id":"rocambole-indent@0.1.0","_shasum":"fd2abd19fa9e1ede274e8a59191ca465e63bda64","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":""}],"dist":{"shasum":"fd2abd19fa9e1ede274e8a59191ca465e63bda64","size":3259,"noattachment":false,"key":"/rocambole-indent/-/rocambole-indent-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rocambole-indent/download/rocambole-indent-0.1.0.tgz"},"directories":{},"publish_time":1426830741073,"_cnpm_publish_time":1426830741073,"_hasShrinkwrap":false}},"readme":"# rocambole-indent\n\nHelpers to manipulate [rocambole](https://github.com/millermedeiros/rocambole)\n`Indent` tokens.\n\nUsed mainly by [esformatter](https://github.com/millermedeiros/esformatter/) and its plugins.\n\n\n## API\n\n```js\nvar indent = require('rocambole-indent');\n```\n\n### setOptions(opts)\n\n`setOptions` used to set the indent value.\n\n```js\nsetOptions({\n  // sets \"value\" used by `Indent` tokens (defaults to two spaces)\n  value: '  ',\n  // amount of indents added on `alignComments` if comment is inside an empty\n  // block (surrounded by `{}`, `[]` or `()`) - defaults to `1`\n  CommentInsideEmptyBlock: 1\n});\n```\n\n### inBetween(startToken, endToken, level)\n\nIncrease/Decrease the indent level in between the `startToken` and `endToken`.\n\nIt will not include the start and end tokens on the indentation range, only the\ntokens in between them.\n\n```js\n// increase the indent level by 1\ninBetween(node.startToken, node.endToken, 1);\n// decrease the indent level by 1\ninBetween(node.startToken, node.endToken, -1);\n// zero does nothing\ninBetween(node.endToken, 0);\n```\n\n**Important:** negative values only work if original `Indent` token contains\na `level` property since there is no reliable way to infer this value (probably\nwill only work if indent was added by this lib).\n\n### addLevel(token, level)\n\nIncreases/decreases the indent level at the beginning of the line that includes\nthe given `token`.\n\n```js\n// adds 2 indents\naddLevel(node.startToken, 2);\n// decrease indent level in 1 step\naddLevel(node.endToken, -1);\n// zero does nothing\naddLevel(node.endToken, 0);\n```\n\n**Important:** negative values only work if original `Indent` token contains\na `level` property since there is no reliable way to infer this value (probably\nwill only work if indent was added by this lib).\n\n### sanitize(astOrNode)\n\nRemoves any `Indent` tokens that don't have a `level` property (this is\nusually the original indentation of the program parsed by rocambole) or that\nare not at the beginning of the line. Also removing `WhiteSpace` tokens that\nare at the beginning of the line to avoid mistakes.\n\n```js\n// sanitize a single node\nsanitize(node);\n// sanitize whole AST\nsanitize(ast);\n```\n\n### updateBlockComment(token)\n\nUpdates `BlockComment` `raw` value to make sure all the lines have the same\n`Indent` level.\n\nThis is called internally by the `addLevel` and `indentInBetween` methods (if\nfirst token of line is a `BlockComment`), so as long as you only use those\nmethods to edit the indent level you shouldn't need to call this.\n\n### alignComments(astOrNode)\n\nAlign all the comments based on the next/previous lines inside a given `ast` or\n`node`.\n\nIt will align the comments with the next line unless the comment block is\nfollowed by an empty line, in that case it will use the previous non-empty line\nas a reference.\n\nExample output:\n\n```js\n// aligned with next line\nswitch (foo) {\n  // aligned with next non-empty line\n\n  case bar:\n    // aligned with next line\n    baz();\n    // this should be aligned with previous line since comment block is\n    // followed by an empty line\n\n  // aligned with next line\n  case biz:\n    // aligned with next line\n    what();\n// aligned with next line\n}\n\nfunction noop() {\n  // indented since it's inside an empty block\n}\n\n// aligned with previous line since it's at the end of program\n```\n\n### whiteSpaceToIndent(token, [indentValue])\n\nConvert `WhiteSpace` token into `Indent` if it's the first token of the line.\n\nYou can pass a custom `indentValue` or it will use the value set by\n`setOptions()` to calculate the indent `level` (basically count how many times\nthis string repeats inside the `token.value`).\n\n```js\nvar token = {\n  type: 'WhiteSpace',\n  value: '\\t\\t\\t',\n  prev: { type: 'LineBreak', value: '\\n' }\n};\nwhiteSpaceToIndent(token, '\\t');\n// edits properties in place\nconsole.log(token.type);  // > \"Indent\"\nconsole.log(token.level); // > 3\n```\n\nThis is useful in case you want to make sure `sanitize` won't remove the\noriginal indents.\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:indent npm test\n```\n\n## License\n\nReleased under the MIT License\n\n","_attachments":{},"homepage":"https://github.com/millermedeiros/rocambole-indent","bugs":{"url":"https://github.com/millermedeiros/rocambole-indent/issues"},"license":"MIT"}