Skip to content

Commit 2dcb9c2

Browse files
Update readme examples with the new API
1 parent 53cffda commit 2dcb9c2

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ let a = {foo: 'bar'}; // or `new Whatever()`
1818
let b = {foo: 'baz'};
1919
let c = {foo: 'qux'};
2020

21-
tree.insertBefore(a, b); // insert a before b
22-
tree.insertAfter(c, b); // insert c after b
21+
tree.insertBefore(b, a); // insert a before b
22+
tree.insertAfter(b, c); // insert c after b
2323

24-
console.log(tree.next(a) === b);
25-
console.log(tree.next(b) === c);
26-
console.log(tree.prev(c) === b);
24+
console.log(tree.nextSibling(a) === b);
25+
console.log(tree.nextSibling(b) === c);
26+
console.log(tree.previousSibling(c) === b);
2727

2828
tree.remove(b);
29-
console.log(tree.next(a) === c);
29+
console.log(tree.nextSibling(a) === c);
3030
```
3131

3232
A tree:
@@ -40,17 +40,17 @@ let a = {};
4040
let b = {};
4141
let c = {};
4242

43-
tree.insertFirst(a, parent); // insert a as the first child
44-
tree.insertLast(c, parent); // insert c as the last child
45-
tree.insertAfter(b, a); // insert b after a, it now has the same parent as a
43+
tree.prependChild(parent, a); // insert a as the first child
44+
tree.appendChild(parent,c ); // insert c as the last child
45+
tree.insertAfter(a, b); // insert b after a, it now has the same parent as a
4646

47-
console.log(tree.first(parent) === a);
48-
console.log(tree.next(tree.first(parent)) === b);
49-
console.log(tree.last(parent) === c);
47+
console.log(tree.firstChild(parent) === a);
48+
console.log(tree.nextSibling(tree.firstChild(parent)) === b);
49+
console.log(tree.lastChild(parent) === c);
5050

5151
let grandparent = {};
52-
tree.insertFirst(parent, grandparent);
53-
console.log(tree.first(tree.first(grandparent)) === a);
52+
tree.prependChild(grandparent, parent);
53+
console.log(tree.firstChild(tree.firstChild(grandparent)) === a);
5454
```
5555

5656
See [api.md](api.md) for more documentation.

0 commit comments

Comments
 (0)