Skip to content

i-e-b/objglob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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",
            }
        }
    ]
}

About

Run glob patterns against JavaScript objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published