From 352dd71aa3d3db6219f65f2a1f4879c2450c6a9e Mon Sep 17 00:00:00 2001 From: lucasfcosta Date: Tue, 11 Oct 2016 16:20:05 -0300 Subject: [PATCH] feat: returns the object in which the value was set. Closes #6 --- index.js | 1 + test/index.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/index.js b/index.js index 5de4402..3e38b6f 100644 --- a/index.js +++ b/index.js @@ -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 = { diff --git a/test/index.js b/test/index.js index b8dea8e..88a0081 100644 --- a/test/index.js +++ b/test/index.js @@ -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); + }); });