aboutsummaryrefslogtreecommitdiff
path: root/node_modules/acorn/README.md
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/acorn/README.md
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/acorn/README.md')
-rw-r--r--node_modules/acorn/README.md49
1 files changed, 46 insertions, 3 deletions
diff --git a/node_modules/acorn/README.md b/node_modules/acorn/README.md
index b7efe2341..bd853c43b 100644
--- a/node_modules/acorn/README.md
+++ b/node_modules/acorn/README.md
@@ -63,9 +63,9 @@ object referring to that same position.
[estree]: https://github.com/estree/estree
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
- either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support for strict
- mode, the set of reserved words, and support for new syntax features.
- Default is 7.
+ either 3, 5, 6 (2015), 7 (2016), 8 (2017), or 9 (2018, partial
+ support). This influences support for strict mode, the set of
+ reserved words, and support for new syntax features. Default is 7.
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
implemented by Acorn.
@@ -268,10 +268,33 @@ simply visit all statements and expressions and not produce a
meaningful state. (An example of a use of state is to track scope at
each point in the tree.)
+```js
+const acorn = require("acorn")
+const walk = require("acorn/dist/walk")
+
+walk.simple(acorn.parse("let x = 10"), {
+ Literal(node) {
+ console.log(`Found a literal: ${node.value}`)
+ }
+})
+```
+
**ancestor**`(node, visitors, base, state)` does a 'simple' walk over
a tree, building up an array of ancestor nodes (including the current node)
and passing the array to the callbacks as a third parameter.
+```js
+const acorn = require("acorn")
+const walk = require("acorn/dist/walk")
+
+walk.ancestor(acorn.parse("foo('hi')"), {
+ Literal(_, ancestors) {
+ console.log("This literal's ancestors are:",
+ ancestors.map(n => n.type))
+ }
+})
+```
+
**recursive**`(node, state, functions, base)` does a 'recursive'
walk, where the walker functions are responsible for continuing the
walk on the child nodes of their target node. `state` is the start
@@ -287,6 +310,23 @@ default walkers will be used.
walker functions in `functions` and filling in the missing ones by
taking defaults from `base`.
+**full**`(node, callback, base, state)` does a 'full'
+walk over a tree, calling the callback with the arguments (node, state, type)
+for each node
+
+**fullAncestor**`(node, callback, base, state)` does a 'full' walk over
+a tree, building up an array of ancestor nodes (including the current node)
+and passing the array to the callbacks as a third parameter.
+
+```js
+const acorn = require("acorn")
+const walk = require("acorn/dist/walk")
+
+walk.full(acorn.parse("1 + 1"), node => {
+ console.log(`There's a ${node.type} node at ${node.ch}`)
+})
+```
+
**findNodeAt**`(node, start, end, test, base, state)` tries to
locate a node in a tree at the given start and/or end offsets, which
satisfies the predicate `test`. `start` and `end` can be either `null`
@@ -407,3 +447,6 @@ looseParser.extend("readToken", function(nextMethod) {
- [`acorn-object-spread`](https://github.com/UXtemple/acorn-object-spread): Parse [object spread syntax proposal](https://github.com/sebmarkbage/ecmascript-rest-spread)
- [`acorn-es7`](https://www.npmjs.com/package/acorn-es7): Parse [decorator syntax proposal](https://github.com/wycats/javascript-decorators)
- [`acorn-objj`](https://www.npmjs.com/package/acorn-objj): [Objective-J](http://www.cappuccino-project.org/learn/objective-j.html) language parser built as Acorn plugin
+ - [`acorn-object-rest-spread`](https://github.com/victor-homyakov/acorn-object-rest-spread) Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread), works with latest Acorn version (5.0.3)
+ - [`acorn-static-class-property-initializer`](https://github.com/victor-homyakov/acorn-static-class-property-initializer) Partial support for static class properties from [ES Class Fields & Static Properties Proposal](https://github.com/tc39/proposal-class-public-fields) to support static property initializers in [React components written as ES6+ classes](https://babeljs.io/blog/2015/06/07/react-on-es6-plus)
+