8000 feat: returns the object in which the value was set. Closes #6 · chaijs/pathval@352dd71 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 352dd71

Browse files
committed
feat: returns the object in which the value was set. Closes #6
1 parent a8aa393 commit 352dd71

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ function getPathValue(obj, path) {
293293
function setPathValue(obj, path, val) {
294294
var parsed = parsePath(path);
295295
internalSetPathValue(obj, val, parsed);
296+
return obj;
296297
}
297298

298299
module.exports = {

test/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,10 @@ describe('setPathValue', function () {
208208
assert(obj.hello[1] === 2);
209209
assert(obj.hello[2] === 3);
210210
});
211+
212+
it('returns the object in which the value was set', function () {
213+
var obj = { hello: [ 1, 2, 4 4B3C ] };
214+
var valueReturned = pathval.setPathValue(obj, 'hello[2]', 3);
215+
assert(obj === valueReturned);
216+
});
211217
});

0 commit comments

Comments
 (0)
0