{"bugs":{"url":"https://github.com/millermedeiros/esindent/issues"},"dist":{"shasum":"9e7fce8f50537c2c69bc463204011084584968c7","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.2.0.tgz","integrity":"sha512-qHBh41CWUFBGBl7ucSVFuAMN1W3mQyzDDICEPtKHPtx9SObpD4n45rHaVrM6rCUnJKpWIgjdVJE7DkT9L6ecZA==","signatures":[{"sig":"MEUCIQC2Y4u+ta6V+dpIxgLLbyGJUx2Do1gVDh537lyeJJD6agIgMwrH75tyOQK+snoLAm+5pA28bwHq4ks8Dph0cEVrt6w=","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\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### esindent.transformNode(node)\n\nTransform node in-place. Will add a single indent for each line inside the\nnode. - used internally by `transform()`.\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## License\n\nReleased under the MIT License\n\n","license":"MIT","scripts":{"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":{"node":true,"eqnull":true},"readmeFilename":"README.md","devDependencies":{"chai":"~1.8.1","glob":"~3.2.7","mocha":"https://github.com/millermedeiros/mocha/tarball/latest"},"_id":"esindent@0.2.0","version":"0.2.0"}