expand-value NPM version NPM monthly downloads NPM total downloads

Expand deeply nested values from an object, with support for advanced features.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.


Install with npm (requires Node.js >=14):

$ npm install --save expand-value


Similar to get-value and dot-prop (and passes all of the get-value unit tests), but supports more complex expressions for accessing deeply nested properties. For example, this library is used by Dry for resolving values in expressions in user-defined templates.

const expand = require('expand-value');

const data = { user: { name: 'Brian' }, key: 'name' };

console.log(expand(data, 'user.name')) //=> 'Brian'
console.log(expand(data, 'user["name"]')) //=> 'Brian'
console.log(expand(data, 'user[key]')) //=> 'Brian'

console.log(expand({ foo: { bar: { baz: 'correct' } } }, 'foo["bar"].baz')); //=> 'correct'


const { parse } = require('expand-value);
const { ast } = parse('a.b.c');


// results in
  type: 'root',
  nodes: [
    { type: 'ident', value: 'a' },
    { type: 'separator', value: '.' },
    { type: 'ident', value: 'b' },
    { type: 'separator', value: '.' },
    { type: 'ident', value: 'c' }



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

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb


Jon Schlinkert


Copyright © 2021, Jon Schlinkert. Released under the MIT License.

This file was generated by verb-generate-readme, v0.8.0, on July 20, 2021.

Expand Value

Expand deeply nested values from an object, with support for advanced features

Expand Value Info

⭐ Stars10
🔗 Source Codegithub.com
🕒 Last Updatea year ago
🕒 Createda year ago
🐞 Open Issues0
➗ Star-Issue RatioInfinity
😎 Authorjonschlinkert