Skip to content

Commit 741c430

Browse files
committed
removed not used function
Signed-off-by: Rocco, Marco <[email protected]>
1 parent 7209394 commit 741c430

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

lib/mcapi/utils/utils.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,6 @@ module.exports.mutateObjectProperty = function (path, value, obj, srcPath, prope
103103
}
104104
};
105105

106-
/**
107-
* Resolve object property using dynamic path
108-
* @param path path in dotted format, example: "first.second.third"
109-
* @param obj Object to query
110-
* @param create {boolean} create the node if not found
111-
* @returns the queried property or null if not found
112-
*/
113-
module.exports.resolveNode = function (path, obj, create) {
114-
if (path && path.length > 0 && obj) {
115-
return path.split('.').reduce(function (prev, curr) {
116-
if (create && !prev[curr]) {
117-
prev[curr] = {};
118-
}
119-
return prev[curr] ? prev[curr] : null;
120-
}, obj);
121-
} else return null;
122-
};
123-
124106
module.exports.deleteNode = function (path, obj, properties) {
125107
properties = properties || [];
126108
let prev = obj;

test/utils.test.js

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -278,62 +278,6 @@ describe("Utils", () => {
278278

279279
});
280280

281-
describe("#resolveNode", () => {
282-
283-
it("when null", () => {
284-
assert.ok(null === utils.resolveNode(null, null, false));
285-
});
286-
287-
it("when path length == 0", () => {
288-
assert.ok(null === utils.resolveNode("", {}, false));
289-
});
290-
291-
it("when not dotted", () => {
292-
assert.ok(null === utils.resolveNode("testpath", {}, false));
293-
});
294-
295-
it("with valid path and obj", () => {
296-
let res = utils.resolveNode("test.path.long", {
297-
test: {
298-
path: {
299-
long: {
300-
foo: "bar"
301-
}
302-
}
303-
}
304-
}, false);
305-
assert.ok(JSON.stringify(res) === JSON.stringify({foo: "bar"}));
306-
});
307-
308-
it("with valid path and obj not found", () => {
309-
let res = utils.resolveNode("test.path.notfound", {
310-
test: {
311-
path: {
312-
long: {
313-
foo: "bar"
314-
}
315-
}
316-
}
317-
}, false);
318-
assert.ok(res === null);
319-
});
320-
321-
it("with valid path and obj not found, create it", () => {
322-
let body = {
323-
test: {
324-
path: {
325-
long: {
326-
foo: "bar"
327-
}
328-
}
329-
}
330-
};
331-
utils.resolveNode("test.path.notfound", body, true);
332-
assert.ok(JSON.stringify(body) === JSON.stringify({"test": {"path": {"long": {"foo": "bar"}, "notfound": {}}}}));
333-
});
334-
335-
});
336-
337281
describe("#deleteNode", () => {
338282

339283
it("with nulls", () => {

0 commit comments

Comments
 (0)