0.0.15-beta.1 • Published 9 years ago

thin-tree v0.0.15-beta.1

Weekly downloads
21
License
MIT
Repository
github
Last release
9 years ago

thin-tree thin-tree build status.

Thin tree helps build recursive structures.

Usage

var TT = require('thin-tree');

var eve = {
    name: "Eve",
    children: [
        {
            name: "Alice",
            age: 7
        },
        {
            name: "Bob",
            age: 5
        }
    ]
}

var eveTree = new TT.Find(eve);
expect('Alice' === eveTree.first().name).toBe(true);
expect('Alice' === eveTree.chain()
            .where({parent: eveTree})
                .first().value().name).toBe(true);
expect('Bob' === eveTree.find({age: 5}).name).toBe(true);

var SomeTree = TT.Find.extend({
    prev: function() {
        return !this.parent ? null
            :   this.parent.at(this.index() - 1);
    },
    next: function() {
        return !this.parent ? null
            :   this.parent.at(this.index() + 1);
    }
});

var someEveTree = new SomeTree(eve);
// Inheritance broken
expect(someEveTree.first().next().name).toBe('Bob'); // Fails
0.0.15-beta.1

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago