JSPM

get-property

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q28250F

Get a nested value from an object.

Package Exports

  • get-property

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-property) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-property NPM version

Get a nested value from an object.

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

License

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


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