Skip to content
Christian Alfoni edited this page Mar 5, 2015 · 7 revisions

Up

var Baobab = require('baobab');

var tree = new Baobab({
  level1: {
    level2: 'yeah'
  }
});

var level2 = tree.select('level1', 'level2');
level2.get(); // "yeah"

var level1 = level2.up();
level1.get(); // { level2: 'yeah' }

Left, right and down

var Baobab = require('baobab');
var tree = new Baobab({
  list: [[1, 2], [3, 4]],
  longList: ['one', 'two', 'three', 'four', 'five']
});

var list = tree.select('list');
var three = tree.select('longList', 2);

// Down to first item, and right to next item
list.down().right().get(); // [3,4]

// Select array at index 1, down to first item, then next item
list.select(1).down().right().get(); // 4

two.leftmost().get(); // 'one'

two.rightmost().get(); // 'five'