diff --git a/README.md b/README.md index bd0f715..9c25178 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ - updates value of `key` only if `key` exists - updates only existing values of `obj` when object is given to `key` - because `set-value` **update** values if exist and **add** if not exist +- returns original object if `key` is not an object or string - returns empty object if `obj` is not an object - returns modified object otherwise -- returns original object if `key` is not an object or string ## Install @@ -26,6 +26,40 @@ npm test ```js var put = require('put-value') +var obj = { + a: { + foo: 'bar' + }, + b: { + bb: 'bbb' + } +} + +put(123) //=> {} +put(obj, {a: {bar: 'baz'}}) //=> same as `obj` +put(obj, 'foo', 'baz') //=> same as `obj` +put(obj, 'foo.bar', 'baz') //=> same as `obj` +put(obj, 'a', {foo: 123}) +//==> { +// a: { +// foo: 123 +// }, +// b: { +// bb: 'bbb' +// } +// } + +put(obj, 'a.foo', {baz: 'aaa'}) +//==> { +// a: { +// foo: { +// baz: 'aaa' +// } +// }, +// b: { +// bb: 'bbb' +// } +// } ```