Skip to content

Commit ca2caf7

Browse files
author
Philipp Alferov
committed
Use 'slice' to clone an array
1 parent 01e1685 commit ca2caf7

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ function orderByParents(list) {
3232
return parents;
3333
}
3434

35-
function clone(obj) {
36-
return JSON.parse(JSON.stringify(obj));
37-
}
38-
3935
module.exports = function(obj) {
40-
var cloned = clone(obj);
36+
var cloned = obj.slice();
4137
var ordered = orderByParents(cloned);
4238
return createTree(ordered, ordered[0]);
4339
};

0 commit comments

Comments
 (0)