{"_id":"to-ast","_rev":"4-4c34a1744effa22f1d76a577e90ce0b3","name":"to-ast","description":"Converts JavaScript objects to equivalent ASTs","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"to-ast","version":"1.0.0","description":"Converts JavaScript objects to equivalent ASTs","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/devongovett/to-ast.git"},"keywords":["ast","object","syntax","escodegen","esprima"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/to-ast/issues"},"homepage":"https://github.com/devongovett/to-ast","devDependencies":{"escodegen":"^1.6.1","mocha":"^2.2.1"},"dependencies":{"ast-types":"^0.7.2","esprima":"^2.1.0"},"gitHead":"872c8c42513aa725feffc72fc5b0a9062e32912d","_id":"to-ast@1.0.0","_shasum":"0c4a31c8c98edfde9aaf0192c794b4c8b11ee287","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"dist":{"shasum":"0c4a31c8c98edfde9aaf0192c794b4c8b11ee287","tarball":"https://registry.npmjs.org/to-ast/-/to-ast-1.0.0.tgz","integrity":"sha512-FZpqARevv2F9BQZAeOx4b8F1tp07qqITCevw5spzKMC7ewcsP4y42kQosjctkAoROtzMNGbmD5n9ZN+vWmSN/Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFLJXKisGGYlWJQuFlpAqHOQ/oYgnc0FoubS74NaAxq9AiEAyLzk2IYqGKbOvDbJ3FVjnFJvN4KdWWeIAh2ftcNg/0A="}]}}},"readme":"# to-ast\n\nThis module converts JavaScript objects to an equivalent abstract syntax tree representation, \ncompatible with the [Mozilla Parser API](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API).\nYou can use it to generate JavaScript source code from objects, using \n[escodegen](https://github.com/estools/escodegen).\n\n## Usage\n\nInstall with npm:\n\n    npm install to-ast\n\nHere's a simple example:\n\n```javascript\n\nvar toAST = require('to-ast');\nvar escodegen = require('escodegen');\n\n// get an AST from a number...\ntoAST(2) //=> { type: 'Literal', value: 2 }\n\n// or if you want a source string...\nescodegen.generate(toAST(2)) //=> '2'\n```\n\n## Supported types\n\n* undefined\n* null\n* number, string, and boolean literals\n* functions\n* Node buffers\n* arrays\n* String, Number, and Boolean object wrappers\n* typed arrays and array buffers\n* dates\n* errors\n* regular expressions\n* object literals\n\n## Custom types\n\nMost built-in JavaScript types as supported out of the box, but if you want to override the behavior for\nyour particular object, you can provide a `toAST` method on your object:\n\n```javascript\nvar toAST = require('to-ast');\nvar escodegen = require('escodegen');\n\nfunction Person(name) {\n  this.name = name;\n}\n\nPerson.prototype.toAST = function() {\n  return {\n    type: 'NewExpression',\n    callee: { type: 'Identifier', name: 'Person' },\n    arguments: [{ type: 'Literal', value: this.name }]\n  };\n};\n\nescodegen.generate(toAST(new Person('Devon'))) //=> \"new Person('Devon')\"\n```\n\n## License\n\nMIT\n","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"time":{"modified":"2022-06-27T07:22:11.271Z","created":"2015-04-02T03:56:10.413Z","1.0.0":"2015-04-02T03:56:10.413Z"},"homepage":"https://github.com/devongovett/to-ast","keywords":["ast","object","syntax","escodegen","esprima"],"repository":{"type":"git","url":"git://github.com/devongovett/to-ast.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"bugs":{"url":"https://github.com/devongovett/to-ast/issues"},"license":"MIT","readmeFilename":"readme.md","users":{"chocolateboy":true}}