@@ -286,7 +286,7 @@ export function getRawInteractiveDocumentMetadataFromNotebookDocumentMetadata(no
286286 return notebookDocumentMetadata ;
287287}
288288
289- export function getRawNotebookDocumentMetadataFromNotebookDocumentMetadata ( notebookDocumentMetadata : NotebookDocumentMetadata , createForIpynb : boolean ) : { [ key : string ] : any } {
289+ export function getRawNotebookDocumentMetadataFromNotebookDocumentMetadata ( notebookDocumentMetadata : NotebookDocumentMetadata , documentRawMetadata : { [ key : string ] : any } , createForIpynb : boolean ) : { [ key : string ] : any } {
290290 const rawMetadata : { [ key : string ] : any } = { } ;
291291
292292 if ( createForIpynb ) {
@@ -301,9 +301,27 @@ export function getRawNotebookDocumentMetadataFromNotebookDocumentMetadata(noteb
301301 rawMetadata . polyglot_notebook = notebookDocumentMetadata ;
302302 }
303303
304+ merge ( rawMetadata , documentRawMetadata ) ;
304305 return rawMetadata ;
305306}
306307
308+ function merge ( destination : { [ key : string ] : any } , source : { [ key : string ] : any } ) {
309+ const sourceKeys = Object . keys ( source ) ;
310+ for ( const key of sourceKeys ) {
311+ if ( destination [ key ] === undefined ) {
312+ destination [ key ] = source [ key ] ;
313+ } else {
314+ if ( source [ key ] !== undefined && source [ key ] !== null ) {
315+ if ( typeof destination [ key ] === 'object' ) {
316+ merge ( destination [ key ] , source [ key ] ) ;
317+ }
318+ } else {
319+ let a = 123 ;
320+ }
321+ }
322+ }
323+ }
324+
307325export function mergeNotebookCellMetadata ( baseMetadata : NotebookCellMetadata , metadataWithNewValues : NotebookCellMetadata ) : NotebookCellMetadata {
308326 const resultMetadata = { ...baseMetadata } ;
309327 if ( metadataWithNewValues . kernelName ) {
@@ -354,10 +372,10 @@ function createDefaultNotebookCellMetadata(): NotebookCellMetadata {
354372 return { } ;
355373}
356374
357- export function areEquivalentObjects ( object1 : { [ key : string ] : any } , object2 : { [ key : string ] : any } ) {
375+ export function areEquivalentObjects ( object1 : { [ key : string ] : any } , object2 : { [ key : string ] : any } ) : boolean {
358376 const isObject = ( object : any ) => {
359377 return object !== null && typeof object === 'object' ;
360- }
378+ } ;
361379
362380 const object1Keys = Object . keys ( object1 ) ;
363381 const object2Keys = Object . keys ( object2 ) ;
@@ -367,28 +385,32 @@ export function areEquivalentObjects(object1: { [key: string]: any }, object2: {
367385 }
368386
369387 for ( const key of object1Keys ) {
388+ key ; //?
370389 const value1 = object1 [ key ] ; //?
371390 const value2 = object2 [ key ] ; //?
372391 const bothAreObjects = isObject ( value1 ) && isObject ( value2 ) ; //?
373- if ( ( bothAreObjects && ! areEquivalentObjects ( value1 , value2 ) ) ) {
374- return false ;
375- }
392+ const bothAreArrays = Array . isArray ( value1 ) && Array . isArray ( value2 ) ;
376393
377- if ( Array . isArray ( value1 ) && Array . isArray ( value2 ) ) {
378- if ( value1 . length !== value2 . length ) {
394+ if ( bothAreArrays ) {
395+ if ( value1 . length !== value2 . length ) { //?
379396 return false ;
380397 }
381-
382398 for ( let index = 0 ; index < value1 . length ; index ++ ) {
383399 const element1 = value1 [ index ] ; //?
384400 const element2 = value2 [ index ] ; //?
385401 if ( ! areEquivalentObjects ( element1 , element2 ) ) {
386402 return false ;
387403 }
388404 }
389-
390- }
391- else if ( value1 !== value2 ) {
405+ } else if ( bothAreObjects ) {
406+ const equivalent = areEquivalentObjects ( value1 , value2 ) ;
407+ if ( ! equivalent ) {
408+ return false ;
409+ }
410+ } else if ( value1 !== value2 ) //?
411+ {
412+ value1 ; //?
413+ value2 ; //?
392414 return false ;
393415 }
394416 }
0 commit comments