vue-set-value

Vue.set with dot notation support (`'a.b.c'`) paths.


Keywords
vue, deep-get-set, deep-object, deep-property, deep-set, deep-set-in, deephas, dot-prop, dot2val, es5-dot-prop, get, getsetdeep, has, hasown, key, keys, lodash.set, nested, notation, object, object-path, object-path-set, object-set, prop, properties, property, props, set, set-deep, set-deep-prop, set-nested-prop, setvalue, value, values
License
MIT
Install
npm install vue-set-value@1.0.3

Documentation

vue-set-value

Create nested values and any intermediaries on vue reactive objects using dot notation ('a.b.c') paths.

This project is only fork of great package set-value made by Jon Schlinkert

Install

Install with npm:

$ npm install --save vue-set-value

Usage

var vueDeepSet = require('vue-set-value');
vueDeepSet(object, prop, value);

Params

  • object {object}: The object to set value on
  • prop {string}: The property to set. Dot-notation may be used.
  • value {any}: The value to set on object[prop]

Examples

Updates and returns the given object:

vueDeepSet(target, 'a.b.c', 'd');
console.log(target);
//=> { a: { b: { c: 'd' } } }

Escaping

Escaping with backslashes

Prevent set-value from splitting on a dot by prefixing it with backslashes:

console.log(vueDeepSet(target, 'a\\.b.c', 'd'));
//=> { 'a.b': { c: 'd' } }

console.log(vueDeepSet(target, 'a\\.b\\.c', 'd'));
//=> { 'a.b.c': 'd' }

License

Copyright © 2018, Yaroslav Dobzhanskij. Copyright © 2018, Jon Schlinkert. Released under the MIT License.