1 ### esutils [](http://travis-ci.org/Constellation/esutils)
2 esutils ([esutils](http://github.com/Constellation/esutils)) is
3 utility box for ECMAScript language tools.
9 #### ast.isExpression(node)
11 Returns true if `node` is an Expression as defined in ECMA262 edition 5.1 section
12 [11](https://es5.github.io/#x11).
14 #### ast.isStatement(node)
16 Returns true if `node` is a Statement as defined in ECMA262 edition 5.1 section
17 [12](https://es5.github.io/#x12).
19 #### ast.isIterationStatement(node)
21 Returns true if `node` is an IterationStatement as defined in ECMA262 edition
22 5.1 section [12.6](https://es5.github.io/#x12.6).
24 #### ast.isSourceElement(node)
26 Returns true if `node` is a SourceElement as defined in ECMA262 edition 5.1
27 section [14](https://es5.github.io/#x14).
29 #### ast.trailingStatement(node)
31 Returns `Statement?` if `node` has trailing `Statement`.
36 When taking this `IfStatement`, returns `consequent;` statement.
38 #### ast.isProblematicIfStatement(node)
40 Returns true if `node` is a problematic IfStatement. If `node` is a problematic `IfStatement`, `node` cannot be represented as an one on one JavaScript code.
45 type: 'WithStatement',
48 consequent: {type: 'EmptyStatement'}
51 alternate: {type: 'EmptyStatement'}
54 The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`.
59 #### code.isDecimalDigit(code)
61 Return true if provided code is decimal digit.
63 #### code.isHexDigit(code)
65 Return true if provided code is hexadecimal digit.
67 #### code.isOctalDigit(code)
69 Return true if provided code is octal digit.
71 #### code.isWhiteSpace(code)
73 Return true if provided code is white space. White space characters are formally defined in ECMA262.
75 #### code.isLineTerminator(code)
77 Return true if provided code is line terminator. Line terminator characters are formally defined in ECMA262.
79 #### code.isIdentifierStart(code)
81 Return true if provided code can be the first character of ECMA262 Identifier. They are formally defined in ECMA262.
83 #### code.isIdentifierPart(code)
85 Return true if provided code can be the trailing character of ECMA262 Identifier. They are formally defined in ECMA262.
89 #### keyword.isKeywordES5(id, strict)
91 Returns `true` if provided identifier string is a Keyword or Future Reserved Word
92 in ECMA262 edition 5.1. They are formally defined in ECMA262 sections
93 [7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2),
94 respectively. If the `strict` flag is truthy, this function additionally checks whether
95 `id` is a Keyword or Future Reserved Word under strict mode.
97 #### keyword.isKeywordES6(id, strict)
99 Returns `true` if provided identifier string is a Keyword or Future Reserved Word
100 in ECMA262 edition 6. They are formally defined in ECMA262 sections
101 [11.6.2.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-keywords) and
102 [11.6.2.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-future-reserved-words),
103 respectively. If the `strict` flag is truthy, this function additionally checks whether
104 `id` is a Keyword or Future Reserved Word under strict mode.
106 #### keyword.isReservedWordES5(id, strict)
108 Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 5.1.
109 They are formally defined in ECMA262 section [7.6.1](http://es5.github.io/#x7.6.1).
110 If the `strict` flag is truthy, this function additionally checks whether `id`
111 is a Reserved Word under strict mode.
113 #### keyword.isReservedWordES6(id, strict)
115 Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 6.
116 They are formally defined in ECMA262 section [11.6.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words).
117 If the `strict` flag is truthy, this function additionally checks whether `id`
118 is a Reserved Word under strict mode.
120 #### keyword.isRestrictedWord(id)
122 Returns `true` if provided identifier string is one of `eval` or `arguments`.
123 They are restricted in strict mode code throughout ECMA262 edition 5.1 and
124 in ECMA262 edition 6 section [12.1.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-static-semantics-early-errors).
126 #### keyword.isIdentifierName(id)
128 Return true if provided identifier string is an IdentifierName as specified in
129 ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
131 #### keyword.isIdentifierES5(id, strict)
133 Return true if provided identifier string is an Identifier as specified in
134 ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6). If the `strict`
135 flag is truthy, this function additionally checks whether `id` is an Identifier
138 #### keyword.isIdentifierES6(id, strict)
140 Return true if provided identifier string is an Identifier as specified in
141 ECMA262 edition 6 section [12.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers).
142 If the `strict` flag is truthy, this function additionally checks whether `id`
143 is an Identifier under strict mode.
147 Copyright (C) 2013 [Yusuke Suzuki](http://github.com/Constellation)
148 (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
150 Redistribution and use in source and binary forms, with or without
151 modification, are permitted provided that the following conditions are met:
153 * Redistributions of source code must retain the above copyright
154 notice, this list of conditions and the following disclaimer.
156 * Redistributions in binary form must reproduce the above copyright
157 notice, this list of conditions and the following disclaimer in the
158 documentation and/or other materials provided with the distribution.
160 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
161 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
163 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
164 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
165 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
166 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
167 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
168 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
169 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.