Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

get-property

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-property

Get a nested property or its value from an object using simple `a.b.c` paths.

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
3
-25%
Maintainers
1
Weekly downloads
 
Created
Source

get-property NPM version

Get a nested property or its value from an object using simple a.b.c paths.

Install

Install with npm:

npm i get-property --save-dev

Run tests

npm test

Usage

var getProperty = require('get-property');

var obj = {a: 'a', b: {c: 'd'}};
get(obj, 'b.c');
//=> {c: 'd'}

Pass true as the last argument to return only the value:

var obj = {a: 'a', b: {c: 'd'}};
get(obj, 'b.c');
//=> 'd'

Examples

get({a: 'a', b: 'b'}, 'a');
//=> {a: 'a'}

get({a: 'a', b: {c: 'd'}}, 'a', true);
//=> 'a'

get({a: 'a', b: {c: 'd'}}, 'b.c');
//=> {c: 'd'}

get({a: 'a', b: {c: 'd'}}, 'b.c', true);
//=> 'd'

get({a: {b: 'c', c: {d: 'e', e: 'f', g: {h: 'i'}}}}, 'a.c.g.h');
//=> {h: 'i'}

get({a: {b: 'c', c: {d: 'e', e: 'f', g: {h: 'i'}}}}, 'a.c.g.h', true);
//=> 'i'

Author

Jon Schlinkert

Other libs

Other javascript/node.js utils that I maintain:

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license

This file was generated by verb-cli on September 22, 2014.

Keywords

check

FAQs

Package last updated on 22 Sep 2014

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