Skip to content

Commit 1457f7a

Browse files
author
sttk
committed
Bugfix for the issue #2
1 parent 4e6cbea commit 1457f7a

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

lib/foreach-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ function foreachNode(node, basekey, fn) {
2323
continue;
2424
}
2525

26-
node[key] = fn(val, keychain.slice(1));
26+
fn(val, keychain.slice(1));
2727
}
2828
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"testrun": "^0.7.0"
4040
},
4141
"dependencies": {
42+
"lodash.assign": "^4.2.0",
4243
"lodash.isplainobject": "^4.0.6",
4344
"lodash.set": "^4.3.2"
4445
}

test/copy-props.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
var assert = require('assert');
44
var testrun = require('testrun').mocha;
5+
var assign = require('lodash.assign');
56
var copyProps = require('../');
67

78
function testfn(testcase) {
9+
var src = assign({}, testcase.src);
810
var ret = copyProps(testcase.src, testcase.dst, testcase.map, testcase.fn);
11+
assert.deepEqual(src, testcase.src);
912
assert.strictEqual(ret, testcase.dst);
1013
return ret;
1114
}

test/foreach-props.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
'use strict';
22

33
var testrun = require('testrun').mocha;
4+
var assert = require('assert');
45
var foreachProps = require('../lib/foreach-props');
6+
var assign = require('lodash.assign');
57

68
function testfn(testcase) {
79
var logs = [];
10+
var src = assign({}, testcase.obj);
811
foreachProps(testcase.obj, function(value, keychain) {
912
logs.push({ keychain: keychain, value: value });
1013
});
14+
assert.deepEqual(testcase.obj, src);
1115
return logs;
1216
}
1317

0 commit comments

Comments
 (0)