1## Escodegen 2[![npm version](https://badge.fury.io/js/escodegen.svg)](http://badge.fury.io/js/escodegen) 3[![Build Status](https://secure.travis-ci.org/estools/escodegen.svg)](http://travis-ci.org/estools/escodegen) 4[![Dependency Status](https://david-dm.org/estools/escodegen.svg)](https://david-dm.org/estools/escodegen) 5[![devDependency Status](https://david-dm.org/estools/escodegen/dev-status.svg)](https://david-dm.org/estools/escodegen#info=devDependencies) 6 7Escodegen ([escodegen](http://github.com/estools/escodegen)) is an 8[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) 9(also popularly known as [JavaScript](http://en.wikipedia.org/wiki/JavaScript)) 10code generator from [Mozilla's Parser API](https://developer.mozilla.org/en/SpiderMonkey/Parser_API) 11AST. See the [online generator](https://estools.github.io/escodegen/demo/index.html) 12for a demo. 13 14 15### Install 16 17Escodegen can be used in a web browser: 18 19 <script src="escodegen.browser.js"></script> 20 21escodegen.browser.js can be found in tagged revisions on GitHub. 22 23Or in a Node.js application via npm: 24 25 npm install escodegen 26 27### Usage 28 29A simple example: the program 30 31 escodegen.generate({ 32 type: 'BinaryExpression', 33 operator: '+', 34 left: { type: 'Literal', value: 40 }, 35 right: { type: 'Literal', value: 2 } 36 }); 37 38produces the string `'40 + 2'`. 39 40See the [API page](https://github.com/estools/escodegen/wiki/API) for 41options. To run the tests, execute `npm test` in the root directory. 42 43### Building browser bundle / minified browser bundle 44 45At first, execute `npm install` to install the all dev dependencies. 46After that, 47 48 npm run-script build 49 50will generate `escodegen.browser.js`, which can be used in browser environments. 51 52And, 53 54 npm run-script build-min 55 56will generate the minified file `escodegen.browser.min.js`. 57 58### License 59 60#### Escodegen 61 62Copyright (C) 2012 [Yusuke Suzuki](http://github.com/Constellation) 63 (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors. 64 65Redistribution and use in source and binary forms, with or without 66modification, are permitted provided that the following conditions are met: 67 68 * Redistributions of source code must retain the above copyright 69 notice, this list of conditions and the following disclaimer. 70 71 * Redistributions in binary form must reproduce the above copyright 72 notice, this list of conditions and the following disclaimer in the 73 documentation and/or other materials provided with the distribution. 74 75THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 76AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 77IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 78ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 79DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 80(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 81LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 82ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 83(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 84THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 85 86#### source-map 87 88SourceNodeMocks has a limited interface of mozilla/source-map SourceNode implementations. 89 90Copyright (c) 2009-2011, Mozilla Foundation and contributors 91All rights reserved. 92 93Redistribution and use in source and binary forms, with or without 94modification, are permitted provided that the following conditions are met: 95 96* Redistributions of source code must retain the above copyright notice, this 97 list of conditions and the following disclaimer. 98 99* Redistributions in binary form must reproduce the above copyright notice, 100 this list of conditions and the following disclaimer in the documentation 101 and/or other materials provided with the distribution. 102 103* Neither the names of the Mozilla Foundation nor the names of project 104 contributors may be used to endorse or promote products derived from this 105 software without specific prior written permission. 106 107THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 108ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 109WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 110DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 111FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 112DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 113SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 114CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 115OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 116OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 117