Skip to content

Commit a803182

Browse files
committed
docs(readme): include new events
1 parent 0c63829 commit a803182

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,32 @@ yarn add @stoplight/json-schema-tree
1919

2020
### Usage
2121

22-
```ts
22+
```js
2323
import { SchemaTree } from '@stoplight/json-schema-tree';
2424

2525
const tree = new SchemaTree(mySchema);
2626

2727
const snapshots = [];
28-
let allowedDepth = 4;
28+
let allowedDepth = 2;
2929

30-
tree.walker.hookInto('stepIn', node => {
31-
return tree.walker.depth >= allowedDepth;
32-
});
30+
tree.walker.hookInto('stepIn', node => tree.walker.depth >= allowedDepth);
3331

3432
tree.walker.hookInto('filter', node => {
3533
return !!node.type?.includes('integer'); // if a schema property is of type integer, it won't be included in the tree
3634
});
3735

38-
tree.walker.on('newNode', node => {
36+
tree.walker.on('enterNode', node => {
3937
// new node in fragment is about to be processed
4038
});
4139

42-
tree.walker.on('enterNode', node => {
40+
tree.walker.on('stepIn', node => {
4341
// node has some children we'll process
4442
});
4543

44+
tree.walker.on('stepOver', node => {
45+
// a node was skipped
46+
});
47+
4648
tree.walker('exitNode', node => {
4749
// node processed
4850
});

0 commit comments

Comments
 (0)