Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# zimmerframe changelog

## 1.1.3

- Add `context.parent`, equivalent to `context.path.at(-1)` ([#23](https://github.com/Rich-Harris/zimmerframe/pull/23))

## 1.1.2

- Keep non-enumerable properties non-enumerable ([#20](https://github.com/Rich-Harris/zimmerframe/pull/20))
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ walk(node, state, visitors);
Each visitor receives a second argument, `context`, which is an object with the following properties and methods:

- `next(state?: State): void` — a function that allows you to control when child nodes are visited, and which state they are visited with. If child visitors transform their inputs, this will return the transformed node (if not, returns `undefined`)
- `path: Node[]` — an array of parent nodes. For example, to get the root node you would do `path.at(0)`; to get the current node's immediate parent you would do `path.at(-1)`
- `path: Node[]` — an array of parent nodes. For example, to get the root node you would do `path.at(0)`
- `parent` - the direct parent of the current node, equivalent to `path.at(-1)`
- `state: State` — an object of the same type as the second argument to `walk`. Visitors can pass new state objects to their children with `next(childState)` or `visit(node, childState)`
- `stop(): void` — prevents any subsequent traversal
- `visit(node: Node, state?: State): Node` — returns the result of visiting `node` with the current set of visitors. If no `state` is provided, children will inherit the current state
Expand Down
Loading