0.1.1 • Published 5 years ago

object-glob v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

object-glob

Basic utility for searching an object for all keys matching a glob pattern.

Installation

  • yarn add object-glob
  • npm install --save object-glob

Usage

import { objectGlob } from "object-glob";

const obj = {
  root: {
    nested: {
      leaf: "leaf"
    },
    alsoNested: {
      branch: "branch"
    },
    leaf: "keys"
  },
  leaf: "only"
};

const filter = objectGlob(obj);

filter("**/leaf");
// {
//   root: {
//     nested: {
//       leaf: "leaf"
//     },
//     leaf: "keys"
//   },
//   leaf: "only"
// }