JSPM

  • Created
  • Published
  • Downloads 11878191
  • Score
    100M100P100Q203997F
  • License

Use property paths (`a.b.c`) get a nested value from an object.

Package Exports

  • get-value

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-value) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-value NPM version Build Status

Use property paths (a.b.c) get a nested value from an object.

Benchmarks

This is 10x faster and more performant than dot-prop, and it passes all of the dot-prop tests.

Of the libs benchmarked, dot-prop was the least performant:

#1: deep
  get-value x 3,308,335 ops/sec ±1.32% (94 runs sampled)
  dot-prop x 197,631 ops/sec ±1.27% (94 runs sampled)
  getobject x 218,635 ops/sec ±1.51% (91 runs sampled)

#2: shallow
  get-value x 5,762,976 ops/sec ±1.21% (95 runs sampled)
  dot-prop x 695,892 ops/sec ±1.42% (95 runs sampled)
  getobject x 724,493 ops/sec ±1.46% (93 runs sampled)

Also, get-value supports escaping dots in paths, which is common when object keys are file paths with extensions, dot-prop does not.

Install with npm

npm i get-value --save

Install with bower

bower install get-value --save

Usage

var get = require('get-value');

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

get(obj, 'a.b.c.d');
//=> 'foo'
  • get-property: Get a nested property or its value from an object using simple a.b.c paths.
  • get-object: Get a object from a property on a nested object.
  • has-value: Returns true if a value exists, false if empty. Works with deeply nested values using… more
  • set-value: Create nested values and any intermediaries using dot notation ('a.b.c') paths.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Running tests

Install dev dependencies:

npm i -d && npm test

Author

Jon Schlinkert

License

Copyright (c) 2014-2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on May 03, 2015.