File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 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 {
5050
5151 // ensure links are instances of DAGLink
5252 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+ )
5860 }
59- } ) . forEach ( ( l ) => {
60- this . addRawLink ( l )
6161 } )
62+
63+ stable . inplace ( this . links , linkSort )
6264 }
6365 }
6466
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ module.exports = function (repo) {
4545 const d2 = new DAGNode ( new Buffer ( 'some data' ) , l2 )
4646 expect ( d1 . toJSON ( ) ) . to . be . eql ( d2 . toJSON ( ) )
4747 expect ( d1 . marshal ( ) ) . to . be . eql ( d2 . marshal ( ) )
48+ expect ( d2 . links ) . to . be . eql ( l2 )
4849 } )
4950
5051 it ( 'create an emtpy node' , function ( done ) {
You can’t perform that action at this time.
0 commit comments