Skip to content

Commit

Permalink
Bugfix for the issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Sep 19, 2016
1 parent 4e6cbea commit 1457f7a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/foreach-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ function foreachNode(node, basekey, fn) {
continue;
}

node[key] = fn(val, keychain.slice(1));
fn(val, keychain.slice(1));
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"testrun": "^0.7.0"
},
"dependencies": {
"lodash.assign": "^4.2.0",
"lodash.isplainobject": "^4.0.6",
"lodash.set": "^4.3.2"
}
Expand Down
3 changes: 3 additions & 0 deletions test/copy-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

var assert = require('assert');
var testrun = require('testrun').mocha;
var assign = require('lodash.assign');
var copyProps = require('../');

function testfn(testcase) {
var src = assign({}, testcase.src);
var ret = copyProps(testcase.src, testcase.dst, testcase.map, testcase.fn);
assert.deepEqual(src, testcase.src);
assert.strictEqual(ret, testcase.dst);
return ret;
}
Expand Down
4 changes: 4 additions & 0 deletions test/foreach-props.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
'use strict';

var testrun = require('testrun').mocha;
var assert = require('assert');
var foreachProps = require('../lib/foreach-props');
var assign = require('lodash.assign');

function testfn(testcase) {
var logs = [];
var src = assign({}, testcase.obj);
foreachProps(testcase.obj, function(value, keychain) {
logs.push({ keychain: keychain, value: value });
});
assert.deepEqual(testcase.obj, src);
return logs;
}

Expand Down

0 comments on commit 1457f7a

Please sign in to comment.