{"_id":"esindent","_rev":"20-40ca94e32d28baa8f6347438bfa6dac2","name":"esindent","description":"ECMAScript code indenter based on Esprima AST and Rocambole","dist-tags":{"latest":"0.4.3"},"versions":{"0.1.0":{"name":"esindent","version":"0.1.0","description":"ECMAScript code indenter based on Esprima AST and Rocambole","main":"lib/esindent.js","directories":{"test":"test"},"scripts":{"test":"istanbul test test/runner.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"},"devDependencies":{"mocha":"https://github.com/millermedeiros/mocha/tarball/latest","istanbul":"~0.1.46","chai":"~1.8.1"},"jshintConfig":{"node":true,"eqnull":true},"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');\nesi.transform(ast, {\n  value: '  ',\n  ArrayExpression: 1,\n  BlockStatement: 1,\n  ChainedMemberExpression: 1,\n  MultipleVariableDeclaration: 1,\n  ObjectExpression: 1,\n  SwitchCase: 1,\n  SwitchStatement: 1,\n  EmptyStatement: 0\n});\n\n// to get the result as a string simply call ast.toString()\nconsole.log( ast.toString() );\n```\n\n\n## License\n\nReleased under the MIT License\n\n","readmeFilename":"README.md","_id":"esindent@0.1.0","dist":{"shasum":"dd4ae7648c1192f4331bc6135ab329e029416ce1","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.1.0.tgz","integrity":"sha512-4r9p6CLbuLwv9fdDmv9yINAxQBv0ZlenCjN5XhXJHQhnrjjfBcKFxN14N9HwZnsXxbFMmqM/U5zE3XmRjBmkQw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB6rNJUbLlvcHF94fCk6kpeO1E1Cfcb+w4Ed0//WjjOsAiBQN/ZnHJRAqVXmiH13GpPyihIMYl1uC2Aye0jnjldcBQ=="}]},"_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"},"0.2.0":{"name":"esindent","version":"0.2.0","description":"ECMAScript code indenter based on Esprima AST and Rocambole","main":"lib/esindent.js","directories":{"test":"test"},"scripts":{"test":"node test/runner.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"},"jshintConfig":{"node":true,"eqnull":true},"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","readmeFilename":"README.md","_id":"esindent@0.2.0","dist":{"shasum":"9e7fce8f50537c2c69bc463204011084584968c7","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.2.0.tgz","integrity":"sha512-qHBh41CWUFBGBl7ucSVFuAMN1W3mQyzDDICEPtKHPtx9SObpD4n45rHaVrM6rCUnJKpWIgjdVJE7DkT9L6ecZA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2Y4u+ta6V+dpIxgLLbyGJUx2Do1gVDh537lyeJJD6agIgMwrH75tyOQK+snoLAm+5pA28bwHq4ks8Dph0cEVrt6w="}]},"_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"},"0.3.0":{"name":"esindent","version":"0.3.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### esindent.transformNode(node)\n\nTransform node in-place. Will add a single indent for each line inside the\nnode. - used internally by `transform()` and by `esformatter` to avoid looping\nthrough all nodes multiple times.\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.3.0","dist":{"shasum":"c359c8dc91088e71e4370f53f1d979f2b6ebb4e9","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.3.0.tgz","integrity":"sha512-SM5g4RhhS6wiaDePFwIbg7CcGjFAwfNgx4bSxYWF6z51mKoym6rCpcEOXeTZmny4uzaTGXL4lrcwrAbx8PYHow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8pKzgGDC/1tAreYyb7GIclDeiLq0jDFLAYojMOrUERAIgGm47wlNL1ugn2A73zoJhsWpWovpVG6qOp/liVwnnBH4="}]},"_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"},"0.3.1":{"name":"esindent","version":"0.3.1","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### esindent.transformNode(node)\n\nTransform node in-place. Will add a single indent for each line inside the\nnode. - used internally by `transform()` and by `esformatter` to avoid looping\nthrough all nodes multiple times.\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.3.1","dist":{"shasum":"1184cc4c11e82482c71c09d4735f068422b633ef","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.3.1.tgz","integrity":"sha512-KslZ1VwFHLAbxX1a8plJOlG2mYdCiGqRblL7on+GcIu6jcDEU3M6kWPOiScS0zPXQ4tBp21urhUlON4pyBR8gg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBjTwFbB69HcroLlhJDiptO1ZJSQpPNW4SdmIKt84BvLAiB644YnIyGJeWDOTq2IoLhTtTVlvF1mOYfDL7Z0QpMd1A=="}]},"_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"},"0.4.0":{"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":"https://registry.npmjs.org/esindent/-/esindent-0.4.0.tgz","integrity":"sha512-A+9ozJwXy5rEtHSWlN2x9XzmjizTGRQKW8UMRO2YuY88x2orTUOBA+xKLAXNsqLvVU/ZTsXCPTrGyPLQmHe5jw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHppC9i0C5MpPfvyQII3ZImtoV7fsxNYeIrC1OLbGPabAiAEaa8/twTirAMbnTTmoW8cI9eD3KzZT8AEVyyAij+ZyA=="}]},"_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"},"0.4.1":{"name":"esindent","version":"0.4.1","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.1","dist":{"shasum":"d2a9fa0ec218a74f73130e7f2aecea6895e1c336","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.4.1.tgz","integrity":"sha512-jIcI5/4Ta2xnhEl0ly0m0/KkHRlYMToMTS+pZVlIsQ5Gbp/ksdVK7LHmdgL1sp74ghr0QnTU8yKxzKOjb/D1hA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFvhO4yf5KUYDp1bR43NShTW5JWAM2N7YKRD+u6oEraHAiEAwhvpe2a7Z9WB7ZeR1tzyawmi/4Olt4BPVQlYIjCwiLg="}]},"_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"},"0.4.2":{"name":"esindent","version":"0.4.2","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.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.2","dist":{"shasum":"f1913c618c2420b63315afdf42b8ecd9d3bef367","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.4.2.tgz","integrity":"sha512-/Z7E9FwbgNOEOyBpqQZKZWdt0pMGiBtc0YeMusipV3IGamqEvONwFYQpZZsZD8fxFx2nWO8HRNvFqj4+tcZcgA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAMVBktC8IfugwhjgjH0ZS/qU3QFrhnsY9dctyARKxatAiBMa+cbxvtczZJtsB7jwdyPEayHezC1vAzD1Pj+1JeCKA=="}]},"_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"},"0.4.3":{"name":"esindent","version":"0.4.3","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.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.3","dist":{"shasum":"6a6b48189d2a25abdef506b448e52732cb7787ab","tarball":"https://registry.npmjs.org/esindent/-/esindent-0.4.3.tgz","integrity":"sha512-Ak0MaSa7qkZz30PrXCLmeKRO37j1Js6tfThUp/CX8D8arvnxDi5UbxHJPNieppj5bN/xxud5gsu3vuAGCD/tTA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCCyasc/5G1S8c7goY3FrjMwVkXfCBsbf4jItaM95GMGwIgdVWlI966MBUeadUEIHy8rubi/sV3CEdvzZRX/7JHaIM="}]},"_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"}},"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');\nesi.transform(ast, {\n  value: '  ',\n  ArrayExpression: 1,\n  BlockStatement: 1,\n  ChainedMemberExpression: 1,\n  MultipleVariableDeclaration: 1,\n  ObjectExpression: 1,\n  SwitchCase: 1,\n  SwitchStatement: 1,\n  EmptyStatement: 0\n});\n\n// to get the result as a string simply call ast.toString()\nconsole.log( ast.toString() );\n```\n\n\n## License\n\nReleased under the MIT License\n\n","maintainers":[{"name":"millermedeiros","email":"miller@millermedeiros.com"}],"time":{"modified":"2022-06-17T17:49:11.752Z","created":"2013-12-09T17:54:51.082Z","0.1.0":"2013-12-09T17:54:55.102Z","0.2.0":"2013-12-12T21:27:44.353Z","0.3.0":"2013-12-13T20:10:47.458Z","0.3.1":"2013-12-13T20:54:12.041Z","0.4.0":"2013-12-14T15:29:58.728Z","0.4.1":"2013-12-15T03:51:14.553Z","0.4.2":"2013-12-15T04:20:22.093Z","0.4.3":"2013-12-16T16:00:43.028Z"},"author":{"name":"Miller Medeiros","email":"contact@millermedeiros.com","url":"http://blog.millermedeiros.com"},"repository":{"type":"git","url":"https://github.com/millermedeiros/esindent.git"}}