New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

get-object-property-values

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-object-property-values

Gets the value of the object property if it exists in a deeply nested object.

latest
Source
npmnpm
Version
1.2.3
Version published
Maintainers
1
Created
Source

get-object-property-values

##Install npm i --save get-property-by-value

##Usage The utility returns the value for given property of the object if the property exists in a deeply nested object.

##Options The functions has 3 parameters.

  • list - could be list of objects or a single object.
  • property - the property of the object.
  • unique - Boolean value, if specified with the list option gives unique set of values in the array of object for the given property.
getPropertyByValue(list, property, unique);

The package can be imported using ES6 import and CJS require.

import {getPropertyByValue} from "get-object-property-values";
OR
const getPropertyByValue = require("get-object-property-values").getPropertyByValue;
For e.g. 

const obj = {
    fauna: {
        mammals : {
            carnivores: {
                family: cat
            }
        }
    }
}

console.log(getPropertyByValue(obj, "fauna.mammals.carnivores.family"));

// cat

const list = [
        {
            fauna: {
                mammals : {
                    type: carnivores,
                    example: cat: ["lion"]
                }
            }
        },
        {
            fauna: {
                mammals : {
                    type: marsupials,
                    example: cat: ["kangaroo"]
                    }
                }
            }
        }
    ]

console.log(getPropertyByValue(list, "fauna.mammals.type"));

//["carnivores", "marsupials"]

Keywords

Object

FAQs

Package last updated on 27 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts