digger-find

The client side find function for digger container trees

npm install digger-find
8 downloads in the last day
21 downloads in the last week
91 downloads in the last month

digger-find

Build status

The client side find function for digger container trees.

Examples

find

Find containers in local data:

var children_data = [{
    name:"Superman",
    rating:7.8,
    _children:[{
        name:"flying"
    },{
        name:"strength"
    }]
},{
    name:"Spiderman",
    rating:7.9,
    _children:[{
        name:"spinwebs"
    },{
        name:"spidersense"
    }]
}]

var superheroes = Container(children_data);

var spiderman = superheroes.find('[rating=7.9]');

sort

Sort containers by function or fieldname - asc only at present:

By field:

var superheroes = Container(children_data);

// title is default
var byname = superheroes.sort();

// sort by fieldname
var byrating = superheroes.sort('rating');

filter

Return a container with the models that return true from the provided function

If the function is a string then do 'container.match' on it.

By field:

var superheroes = Container(children_data);

var some = superheroes.filter(function(hero){
    return hero.hasClass('super');
})

var byselector = superheroes.filter('.super');

match

Returns true if a given container matches the given selector.

var superheroes = Container(children_data);

var spiderman = superheroes.eq(1);

if(spiderman.match('.super')){
    // spiderman is super!
}
npm loves you