Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

object-path-get

skratchdot497MIT1.0.1

get values from javascript objects by specifying a path

object, path, helper, deep

readme

object-path-get

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

get values from javascript objects by specifying a path.

by using this library, you can help prevent the following error from occurring:

Cannot read property 'foo' of undefined

NOTE: I've re-written / used this function so many different times, I decided to publish it as a module.

Getting Started

Install the module with: npm install --save object-path-get

var getPath = require('object-path-get');
var obj = { foo: { bar: 'baz' } };
getPath(obj, 'foo.bar'); // result: "baz"
getPath(obj, 'foo.invalidKey', 'cool'); // result: "cool"
getPath(obj, 'foo|bar', null, '|'); // result: "baz" (with different delimiter)
getPath(obj, ['foo', 'bar']); // result "baz" (with array path)

Contributors

Thanks goes to these wonderful people (emoji key):



💻 📖 💡

danigb

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

changelog

Unreleased (2020-07-26)

1.0.1 (2020-07-26)

  • add prettier and npm run build (ef101c1)
  • adding npm run watch (9948c22)
  • adding contributors (9e8304a)
  • only run travis on node versions >= 4.0 (e5cf3b6)
  • rename tonic to runkit (6382a24)
  • small readme tweaks (ea9428a)
  • small tweak to runkit script (1bc0111)
  • travis runs node 6+ (7a928b8)
  • update travis config (e2e8369)
  • updating changelog and changelog generator (587c9b6)
  • updating libs and fixing lint errors (0bdbebd)
  • updating libs and moving to jest (a64e222)
  • use prettier on markdown files (626112f)

1.0.0 (2016-08-27)

  • Add support for array paths (8631b98)
  • adding a few more tests (6607e8e)
  • adding changelog and bumping version (d7299ee)
  • removing gulp in favor of npm-scripts (3b380e0)
  • small coding style tweak (5b3eff9)

0.0.3 (2015-11-20)

  • adding mocha and istanbul for test coverage (8a23164)
  • adding tonic example to README.md (7ef679c)
  • fixing coveralls badge (a5b8a4a)
  • fixing travis build and coveralls support (ad8f26a)
  • removing unused .jshintrc (eb7efc3)

0.0.2 (2014-09-16)

  • allow inherited properties to be found. (693e9cf)

0.0.1 (2014-09-15)