Skip to content
This repository has been archived by the owner. It is now read-only.

tiaanduplessis/get-nested-prop

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

get-nested-prop

Get a nested prop using dot-notation with a optional default value as fallback



Built with ❤︎ by Tiaan and contributors

Table of Contents

Table of Contents
  • Install
  • Usage
  • Contribute
  • License
  • Install

    Greenkeeper badge

    $ npm install --save get-nested-prop
    # OR
    $ yarn add get-nested-prop

    Usage

    const getNestedProp = require('get-nested-prop')
    
    const obj = {
      foo: {
        bar: {
          baz: 5
        }
      }
    }
    
    console.log(getNestedProp(obj, 'foo.bar.baz')) // 5
    console.log(getNestedProp(obj, 'foo.bar.baz.boo', 5))  // 5

    Contribute

    Contributions are welcome. Please open up an issue or create PR if you would like to help out.

    Note: If editing the README, please conform to the standard-readme specification.

    License

    Licensed under the MIT License.

    About

    A one-liner to get a nested prop using dot-notation with a optional default value as fallback

    Topics

    Resources

    License

    Stars

    Watchers

    Forks

    Packages

    No packages published