diff options
Diffstat (limited to 'node_modules/set-value/README.md')
-rw-r--r-- | node_modules/set-value/README.md | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/node_modules/set-value/README.md b/node_modules/set-value/README.md index 19fbdbb4d..e336d744e 100644 --- a/node_modules/set-value/README.md +++ b/node_modules/set-value/README.md @@ -1,4 +1,4 @@ -# set-value [](https://www.npmjs.com/package/set-value) [](https://npmjs.org/package/set-value) [](https://npmjs.org/package/set-value) [](https://travis-ci.org/jonschlinkert/set-value) +# set-value [](https://www.npmjs.com/package/set-value) [](https://npmjs.org/package/set-value) [](https://npmjs.org/package/set-value) [](https://travis-ci.org/jonschlinkert/set-value) > Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. @@ -14,13 +14,82 @@ $ npm install --save set-value ```js var set = require('set-value'); +set(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: + +```js var obj = {}; set(obj, 'a.b.c', 'd'); console.log(obj); -//=> {a: {b: c: 'd'}} +//=> { a: { b: { c: 'd' } } } +``` + +### Escaping + +**Escaping with backslashes** + +Prevent set-value from splitting on a dot by prefixing it with backslashes: + +```js +console.log(set({}, 'a\\.b.c', 'd')); +//=> { 'a.b': { c: 'd' } } + +console.log(set({}, 'a\\.b\\.c', 'd')); +//=> { 'a.b.c': 'd' } +``` + +**Escaping with double-quotes or single-quotes** + +Wrap double or single quotes around the string, or part of the string, that should not be split by set-value: + +```js +console.log(set({}, '"a.b".c', 'd')); +//=> { 'a.b': { c: 'd' } } + +console.log(set({}, "'a.b'.c", "d")); +//=> { 'a.b': { c: 'd' } } + +console.log(set({}, '"this/is/a/.file.path"', 'd')); +//=> { 'this/is/a/file.path': 'd' } +``` + +### Bracket support + +set-value does not split inside brackets or braces: + +```js +console.log(set({}, '[a.b].c', 'd')); +//=> { '[a.b]': { c: 'd' } } + +console.log(set({}, "(a.b).c", "d")); +//=> { '(a.b)': { c: 'd' } } + +console.log(set({}, "<a.b>.c", "d")); +//=> { '<a.b>': { c: 'd' } } + +console.log(set({}, "{a..b}.c", "d")); +//=> { '{a..b}': { c: 'd' } } ``` +## History + +### v2.0.0 + +* Adds support for escaping with double or single quotes. See [escaping](#escaping) for examples. +* Will no longer split inside brackets or braces. See [bracket support](#bracket-support) for examples. + +If there are any regressions please create a [bug report](../../issues/new). Thanks! + ## About ### Related projects @@ -42,7 +111,7 @@ Pull requests and stars are always welcome. For bugs and feature requests, [plea | **Commits** | **Contributor** | | --- | --- | -| 53 | [jonschlinkert](https://github.com/jonschlinkert) | +| 59 | [jonschlinkert](https://github.com/jonschlinkert) | | 1 | [vadimdemedes](https://github.com/vadimdemedes) | | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) | @@ -78,4 +147,4 @@ Released under the [MIT License](LICENSE). *** -_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 22, 2017._
\ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 21, 2017._
\ No newline at end of file |