{"name":"esindent","version":"0.4.0","description":"ECMAScript code indenter based on Esprima AST and Rocambole","main":"lib/esindent.js","directories":{"test":"test"},"scripts":{"test":"node test/runner.js","lint":"jshint lib/*.js test/*.js"},"repository":{"type":"git","url":"https://github.com/millermedeiros/esindent.git"},"keywords":["indent","code","esprima","esformatter","rocambole","ast","javascript","ecmascript","formatter"],"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://blog.millermedeiros.com"},"license":"MIT","bugs":{"url":"https://github.com/millermedeiros/esindent/issues"},"homepage":"https://github.com/millermedeiros/esindent","dependencies":{"rocambole":"~0.2.3","rocambole-token":"~1.0","rocambole-node":"~1.0","mout":"~0.8.0"},"devDependencies":{"mocha":"https://github.com/millermedeiros/mocha/tarball/latest","chai":"~1.8.1","glob":"~3.2.7","jshint":"~2.3.0"},"jshintConfig":{"node":true,"eqnull":true,"boss":true,"undef":true,"unused":true,"latedef":false},"readme":"# esindent\n\n[![Build Status](https://travis-ci.org/millermedeiros/esindent.png?branch=master)](https://travis-ci.org/millermedeiros/esindent)\n\nECMAScript code indenter based on Esprima AST\n\n**work in progress**\n\n---\n\n## Why?\n\nThis project started as an experiment while trying to [decouple the indent\nlogic from the other token manipulations on\nesformatter](https://github.com/millermedeiros/esformatter/issues/96). It's an\nattempt at finding a simpler solution to the problem while still maintaining\nthe flexibility.\n\nBy building it as a separate tool it is also simpler to reuse it for other\nprojects and will make some of the tests simpler to write (since we can test\nthe indentation separately).\n\n\n## How?\n\nThis tool uses a rocambole generated AST to traverse tokens inside each node\nand add/remove indent based on the node type.\n\nThe algorithm is very straightforward, it simple loops through all nodes\n(starting from the leaf) up to the program root, scanning each line start for\n`WhiteSpace` and adding/removing/editing `Indent` tokens as needed.\n\n\n## Goals\n\n - Indent based on syntax (not tokens).\n - Options to toggle behavior.\n - Be able to indent any JavaScript program!\n\n\n## API\n\n### esindent.transform(ast[, opts]):AST\n\nTransforms AST in-place, adding `Indent` tokens at the beginning of each line\nthat needs indentation.\n\n```js\nvar esi = require('esindent');\nesindent.transform(ast, {\n  value: '  ',\n  ArrayExpression: 1,\n  ChainedMemberExpression: 1,\n  MultipleVariableDeclaration: 1,\n  ObjectExpression: 1,\n  SwitchCase: 1,\n  SwitchStatement: 1,\n  EmptyStatement: 0,\n  ForStatement: 1,\n  IfStatement: 1,\n  FunctionDeclaration: 1,\n  FunctionExpression: 1,\n  TryStatement: 1,\n  DoWhileStatement: 1\n});\n\n// to get the result as a string simply call ast.toString()\nconsole.log( ast.toString() );\n```\n\n\n### esindent.sanitize(ast)\n\nRemove `WhiteSpace` tokens that are at the beginning of the lines (probably\nfrom original indent or trailing white spaces). Also remove `Indent` tokens\nthat doesn't have the `level` property or that are not preceded by a line\nbreak.\n\n\n### esindent.setOptions(opts)\n\nSet the indent options. Useful for cases where you want to use\n`transformNode()` or call `transform()` multiple times in a row (so you don't\nneed to set the options multiple times). - Used internally by\n`esindent.transform()`.\n\n\n## License\n\nReleased under the MIT License\n\n","readmeFilename":"README.md","_id":"esindent@0.4.0","dist":{"shasum":"39ef59c16cf00f82f65241a592c06e7ce2474654","tarball":"http://registry-npm.ywwl.com/esindent/download/esindent-0.4.0.tgz","integrity":"sha512-A+9ozJwXy5rEtHSWlN2x9XzmjizTGRQKW8UMRO2YuY88x2orTUOBA+xKLAXNsqLvVU/ZTsXCPTrGyPLQmHe5jw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHppC9i0C5MpPfvyQII3ZImtoV7fsxNYeIrC1OLbGPabAiAEaa8/twTirAMbnTTmoW8cI9eD3KzZT8AEVyyAij+ZyA=="}],"size":9030,"noattachment":false,"key":"/esindent/-/esindent-0.4.0.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"maintainers":[{"name":"millermedeiros","email":"miller@millermedeiros.com"}],"deprecated":"use esformatter instead, since this project is not maintained anymore","publish_time":1387034998728,"_cnpm_publish_time":1387034998728,"dist-tags":{"latest":"0.4.3"}}