objglob
Run glob-like patterns against JavaScript objects
Last updated 3 years ago by ieb .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install objglob 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.3                                ...           latest (3 years ago)

3 Versions

  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |