object-path-get
get values from javascript objects by specifying a path
Last updated 4 years ago by skratchdot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install object-path-get 
SYNC missed versions from official npm registry.

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 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)

Links

License

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

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

4 Versions

  • 1.0.0                                ...           4 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 3
Last Month 14
Dependencies (0)
None
Dev Dependencies (7)

Copyright 2014 - 2017 © taobao.org |