@@ -31,71 +31,83 @@ export class StandardMetadataManager implements RunMetadataManager {
3131 ) { }
3232
3333 get parent ( ) : RunMetadataUpdater {
34- return {
34+ // Store a reference to 'this' to ensure proper context
35+ const self = this ;
36+
37+ // Create the updater object and store it in a local variable
38+ const parentUpdater : RunMetadataUpdater = {
3539 set : ( key , value ) => {
36- this . queuedParentOperations . add ( { type : "set" , key, value } ) ;
37- return this . parent ;
40+ self . queuedParentOperations . add ( { type : "set" , key, value } ) ;
41+ return parentUpdater ;
3842 } ,
3943 del : ( key ) => {
40- this . queuedParentOperations . add ( { type : "delete" , key } ) ;
41- return this . parent ;
44+ self . queuedParentOperations . add ( { type : "delete" , key } ) ;
45+ return parentUpdater ;
4246 } ,
4347 append : ( key , value ) => {
44- this . queuedParentOperations . add ( { type : "append" , key, value } ) ;
45- return this . parent ;
48+ self . queuedParentOperations . add ( { type : "append" , key, value } ) ;
49+ return parentUpdater ;
4650 } ,
4751 remove : ( key , value ) => {
48- this . queuedParentOperations . add ( { type : "remove" , key, value } ) ;
49- return this . parent ;
52+ self . queuedParentOperations . add ( { type : "remove" , key, value } ) ;
53+ return parentUpdater ;
5054 } ,
5155 increment : ( key , value ) => {
52- this . queuedParentOperations . add ( { type : "increment" , key, value } ) ;
53- return this . parent ;
56+ self . queuedParentOperations . add ( { type : "increment" , key, value } ) ;
57+ return parentUpdater ;
5458 } ,
5559 decrement : ( key , value ) => {
56- this . queuedParentOperations . add ( { type : "increment" , key, value : - Math . abs ( value ) } ) ;
57- return this . parent ;
60+ self . queuedParentOperations . add ( { type : "increment" , key, value : - Math . abs ( value ) } ) ;
61+ return parentUpdater ;
5862 } ,
5963 update : ( value ) => {
60- this . queuedParentOperations . add ( { type : "update" , value } ) ;
61- return this . parent ;
64+ self . queuedParentOperations . add ( { type : "update" , value } ) ;
65+ return parentUpdater ;
6266 } ,
63- stream : ( key , value , signal ) => this . doStream ( key , value , "parent" , this . parent , signal ) ,
67+ stream : ( key , value , signal ) => self . doStream ( key , value , "parent" , parentUpdater , signal ) ,
6468 } ;
69+
70+ return parentUpdater ;
6571 }
6672
6773 get root ( ) : RunMetadataUpdater {
68- return {
74+ // Store a reference to 'this' to ensure proper context
75+ const self = this ;
76+
77+ // Create the updater object and store it in a local variable
78+ const rootUpdater : RunMetadataUpdater = {
6979 set : ( key , value ) => {
70- this . queuedRootOperations . add ( { type : "set" , key, value } ) ;
71- return this . root ;
80+ self . queuedRootOperations . add ( { type : "set" , key, value } ) ;
81+ return rootUpdater ;
7282 } ,
7383 del : ( key ) => {
74- this . queuedRootOperations . add ( { type : "delete" , key } ) ;
75- return this . root ;
84+ self . queuedRootOperations . add ( { type : "delete" , key } ) ;
85+ return rootUpdater ;
7686 } ,
7787 append : ( key , value ) => {
78- this . queuedRootOperations . add ( { type : "append" , key, value } ) ;
79- return this . root ;
88+ self . queuedRootOperations . add ( { type : "append" , key, value } ) ;
89+ return rootUpdater ;
8090 } ,
8191 remove : ( key , value ) => {
82- this . queuedRootOperations . add ( { type : "remove" , key, value } ) ;
83- return this . root ;
92+ self . queuedRootOperations . add ( { type : "remove" , key, value } ) ;
93+ return rootUpdater ;
8494 } ,
8595 increment : ( key , value ) => {
86- this . queuedRootOperations . add ( { type : "increment" , key, value } ) ;
87- return this . root ;
96+ self . queuedRootOperations . add ( { type : "increment" , key, value } ) ;
97+ return rootUpdater ;
8898 } ,
8999 decrement : ( key , value ) => {
90- this . queuedRootOperations . add ( { type : "increment" , key, value : - Math . abs ( value ) } ) ;
91- return this . root ;
100+ self . queuedRootOperations . add ( { type : "increment" , key, value : - Math . abs ( value ) } ) ;
101+ return rootUpdater ;
92102 } ,
93103 update : ( value ) => {
94- this . queuedRootOperations . add ( { type : "update" , value } ) ;
95- return this . root ;
104+ self . queuedRootOperations . add ( { type : "update" , value } ) ;
105+ return rootUpdater ;
96106 } ,
97- stream : ( key , value , signal ) => this . doStream ( key , value , "root" , this . root , signal ) ,
107+ stream : ( key , value , signal ) => self . doStream ( key , value , "root" , rootUpdater , signal ) ,
98108 } ;
109+
110+ return rootUpdater ;
99111 }
100112
101113 public enterWithMetadata ( metadata : Record < string , DeserializedJson > ) : void {
0 commit comments