Skip to content

Commit

Permalink
feat: returns the object in which the value was set. Closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Oct 11, 2016
1 parent a8aa393 commit 352dd71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ function getPathValue(obj, path) {
function setPathValue(obj, path, val) {
var parsed = parsePath(path);
internalSetPathValue(obj, val, parsed);
return obj;
}

module.exports = {
Expand Down
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,10 @@ describe('setPathValue', function () {
assert(obj.hello[1] === 2);
assert(obj.hello[2] === 3);
});

it('returns the object in which the value was set', function () {
var obj = { hello: [ 1, 2, 4 ] };
var valueReturned = pathval.setPathValue(obj, 'hello[2]', 3);
assert(obj === valueReturned);
});
});

0 comments on commit 352dd71

Please sign in to comment.