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