get-value
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
isobject | 3.0.1 | 2.77 kB | MIT | prod |
Get-Value is a powerful JavaScript utility that allows developers to extract nested values from an object using property paths like 'a.b.c'. The library uniquely also supports keys that include dots, which sets it apart from other dot-prop libraries. It's a fast and efficient tool that enables more advanced object manipulation — it can function with arrays, functions, and can even handle default options when a value can't be resolved in your provided JavaScript object.
To use Get-Value, you would first need to install the package using npm with the command npm install --save get-value
. After installation, you can use it in your JavaScript file as per the following examples:
const get = require('get-value');
const obj = { a: { b: { c: { d: 'foo' } } } };
console.log(get(obj)); //=> { a: { b: { c: { d: 'foo' } } } };
console.log(get(obj, 'a')); //=> { b: { c: { d: 'foo' } } }
console.log(get(obj, 'a.b')); //=> { c: { d: 'foo' } }
console.log(get(obj, 'a.b.c')); //=> { d: 'foo' }
console.log(get(obj, 'a.b.c.d')); //=> 'foo'
The complete documentation and additional usage options for Get-Value can be found on the GitHub page. The README file contains a comprehensive guide, starting with installation and usage instructions, followed by further details on support features and optimization options. This includes examples of using Get-Value with keys that include dots, arrays, and functions, as well as how to pass the object path as an array for increased performance. The documentation also delves into custom options that users can utilize, like defining a default return value or customizing how the object path is split.