2.0.0 • Published 7 years ago

object-description-filter v2.0.0

Weekly downloads
75
License
MIT
Repository
-
Last release
7 years ago

object-description-filter

CircleCI

Pass in an object, and a nested description of the desired return object. Return will be filtered version of passed in object based on description. Will ignore keys in the description if they don't exist in the base object.

use

npm i --save object-description-filter

var objectDescriptionFilter = require('object-description-filter');

var obj = {
  nice: "dope",
  cool: "wow",
  luther: {
    cool: {
      dope: {
        wow: "nice",
        nice: "not"
      }
    }
  }
};

var description = {
  nice: true,
  luther: {
    cool: {
      dope: {
        wow: true,
        super: true
      }
    }
  }
};

var filtered = objectDescriptionFilter(obj, description);
/* returns 
{
  "nice": "dope",
  "luther": {
    "cool": {
      "dope": {
        "wow": "nice"
      }
    }
  }
}
/*
2.0.0

7 years ago

1.1.3

8 years ago

1.1.2-alpha1

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago