Git Product home page Git Product logo

glob-object's Introduction

glob-object NPM version NPM monthly downloads NPM total downloads Linux Build Status

Filter an object using glob patterns and dot notation.

Install

Install with npm:

$ npm install --save glob-object

Usage

var globObject = require('glob-object');

globObject('a.*.f', {a: {b: {c: 'd'}, e: {f: 'g'}}});
//=> { a: { e: { f: 'g' } } }

Examples

Given the following object:

var obj = {
  a: {
    b: {
      c: 'd',
      e: 'f',
      g: 'h',
      i: {j: 'k'},
      l: {g: 'k'}
    },
    i: 'j'
  }
};

match properties using wildcards

globObject('*', obj);
//=> obj (matches all keys)

match properties using braces

globObject('a.*.{c,e}', obj);
//=> {a: {b: {c: 'd', e: 'f'}}}

match a nested property using a wildcard

A single star will match one level of the object:

globObject('a.*.g', obj);
//=> {a: {b: {g: 'h'}}}

match deep properties using globstars

A double star will match to any depth (note that the single star in the previous example did not match a.b.l.g):

globObject('a.**.g', obj);
//=> {a: {b: {g: 'h', l: {g: 'k'}}}}

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on June 19, 2017.

glob-object's People

Contributors

jonschlinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

glob-object's Issues

Update clone-deep dependency version to latest (4.0.0)

Getting the following webpack warning when trying to build my app with require 'glob-object' in a file:

WARNING in ./node_modules/glob-object/node_modules/shallow-clone/utils.js 3:34-41
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

I think this is due to using an old version of clone-deep which in turn depends on an older version of shallow-clone.

I'm using webpack with babel (all latest).

I think it would be good to update your dependencies to the latest anyway?

Upgrade of Package

Hi Jon

I'm using your [email protected] with a dependency [email protected], the dependency are outdated and have been flagged with a vulnerability and was rectified in version 2.0.1 & 3.02

Would it be possible for you to update [email protected] to use the latest dependencies. Or supply alternative suggestions.

Many Thanks in Advance & for the lib that you made available. It is valuable to us.

Regards

How to handle matching slashes "/" on property keys?

I know slash is handled special in regular pathing glob due to special meaning in file systems. However, they do not have the same meaning with object paths. It seems dot ('.') is used for that purpose, which doesn't have the same meaning in regular file path globs. So how does one match property keys which contain slashes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.