{"bugs":{"url":"https://github.com/millermedeiros/esindent/issues"},"dist":{"shasum":"d2a9fa0ec218a74f73130e7f2aecea6895e1c336","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.4.1.tgz","integrity":"sha512-jIcI5/4Ta2xnhEl0ly0m0/KkHRlYMToMTS+pZVlIsQ5Gbp/ksdVK7LHmdgL1sp74ghr0QnTU8yKxzKOjb/D1hA==","signatures":[{"sig":"MEUCIFvhO4yf5KUYDp1bR43NShTW5JWAM2N7YKRD+u6oEraHAiEAwhvpe2a7Z9WB7ZeR1tzyawmi/4Olt4BPVQlYIjCwiLg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/esindent.js","name":"esindent","_from":".","author":{"url":"http://blog.millermedeiros.com","name":"Miller Medeiros","email":"contact@millermedeiros.com"},"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","license":"MIT","scripts":{"lint":"jshint lib/*.js test/*.js","test":"node test/runner.js"},"_npmUser":{"name":"millermedeiros","email":"miller@millermedeiros.com"},"homepage":"https://github.com/millermedeiros/esindent","keywords":["indent","code","esprima","esformatter","rocambole","ast","javascript","ecmascript","formatter"],"deprecated":"use esformatter instead, since this project is not maintained anymore","repository":{"url":"https://github.com/millermedeiros/esindent.git","type":"git"},"_npmVersion":"1.3.14","description":"ECMAScript code indenter based on Esprima AST and Rocambole","directories":{"test":"test"},"maintainers":[{"name":"millermedeiros","email":"miller@millermedeiros.com"}],"dependencies":{"mout":"~0.8.0","rocambole":"~0.2.3","rocambole-node":"~1.0","rocambole-token":"~1.0"},"jshintConfig":{"boss":true,"node":true,"undef":true,"eqnull":true,"unused":true,"latedef":false},"readmeFilename":"README.md","devDependencies":{"chai":"~1.8.1","glob":"~3.2.7","mocha":"https://github.com/millermedeiros/mocha/tarball/latest","jshint":"~2.3.0"},"_id":"esindent@0.4.1","version":"0.4.1"}