File tree 2 files changed +10
-7
lines changed 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -50,15 +50,17 @@ module.exports = class DAGNode {
50
50
51
51
// ensure links are instances of DAGLink
52
52
if ( links ) {
53
- links . map ( ( l ) => {
54
- return {
55
- size : l . size || l . Size ,
56
- name : l . name || l . Name ,
57
- hash : l . hash || l . Hash
53
+ links . forEach ( ( l ) => {
54
+ if ( l . name && typeof l . toJSON === 'function' ) {
55
+ this . links . push ( l )
56
+ } else {
57
+ this . links . push (
58
+ new DAGLink ( l . Name , l . Size , l . Hash )
59
+ )
58
60
}
59
- } ) . forEach ( ( l ) => {
60
- this . addRawLink ( l )
61
61
} )
62
+
63
+ stable . inplace ( this . links , linkSort )
62
64
}
63
65
}
64
66
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ module.exports = function (repo) {
45
45
const d2 = new DAGNode ( new Buffer ( 'some data' ) , l2 )
46
46
expect ( d1 . toJSON ( ) ) . to . be . eql ( d2 . toJSON ( ) )
47
47
expect ( d1 . marshal ( ) ) . to . be . eql ( d2 . marshal ( ) )
48
+ expect ( d2 . links ) . to . be . eql ( l2 )
48
49
} )
49
50
50
51
it ( 'create an emtpy node' , function ( done ) {
You can’t perform that action at this time.
0 commit comments