0.0.3 • Published 8 years ago

objglob v0.0.3

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
8 years ago

objglob

Run glob-like patterns against JavaScript objects

A simple recursive wrapper around https://github.com/isaacs/minimatch

Use

Like this

var filter = require('objglob').filter;
var result = filter(['pattern/**', 'globs'], inputObject);

The objective is to take something like this:

{
    "name":"root",
    "_attr": {
        "id":"x"
    },

    "link": [
        {
            "type":"A",
            "child": {
                "name":"a-child",
                "class":"beta"
            }
        },
        {
            "type":"B",
            "child": {
                "_attr": {
                    "id":"y",
                    "name":"identifier"
                },
                "name":"b-child",
                "class":"beta"
            }
        }
    ]
}

and apply a script to it like this:

!**/_attr
**/name

then end up with

{
    "name":"root",
    "link": [
        {
            "child": {
                "name":"a-child",
            }
        },
        {
            "child": {
                "name":"b-child",
            }
        }
    ]
}
0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

9 years ago