Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Jun 25, 2015
1 parent 1bdf916 commit 1411592
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Expand Up @@ -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
Expand All @@ -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'
// }
// }
```


Expand Down

0 comments on commit 1411592

Please sign in to comment.