diff --git a/index.js b/index.js index ea716c8..1ec2148 100644 --- a/index.js +++ b/index.js @@ -280,6 +280,7 @@ function getPathValue(obj, path) { function setPathValue(obj, path, val) { var parsed = parsePath(path); internalSetPathValue(obj, val, parsed); + return obj; } module.exports = { diff --git a/test/index.js b/test/index.js index c24f668..ce0885c 100644 --- a/test/index.js +++ b/test/index.js @@ -216,4 +216,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); + }); });