@@ -102,10 +102,6 @@ export class GroupBy {
102102 */
103103 col ( col_names ) {
104104
105- // if(!this.column_name.includes(col_name)){
106- // throw new Error(`Column ${col_name} does not exist in groups`)
107- // }
108-
109105 if ( Array . isArray ( col_names ) ) {
110106
111107 for ( let i = 0 ; i < col_names . length ; i ++ ) {
@@ -179,7 +175,11 @@ export class GroupBy {
179175 "cummin" : "cummin().values"
180176 } ;
181177 let is_array = false ;
182-
178+ //the local variable to store variables to be used in eval
179+ // this seems not to be needed in Node version, since local
180+ //variable are easily accessed in the eval function
181+ let local = null ;
182+
183183 if ( Array . isArray ( operation ) ) {
184184 is_array = true ;
185185 }
@@ -201,10 +201,12 @@ export class GroupBy {
201201 if ( ! ops_name . includes ( op ) ) {
202202 throw new Error ( "operation does not exist" ) ;
203203 }
204- data = eval ( `this.group_col[key1][key2][i].${ ops_map [ op ] } ` ) ;
204+ local = this . group_col [ key1 ] [ key2 ] [ i ] ;
205+ data = eval ( `local.${ ops_map [ op ] } ` ) ;
205206
206207 } else {
207- data = eval ( `this.group_col[key1][key2][i].${ operation } ` ) ;
208+ local = this . group_col [ key1 ] [ key2 ] [ i ] ;
209+ data = eval ( `local.${ operation } ` ) ;
208210 }
209211 count_group [ key1 ] [ key2 ] . push ( data ) ;
210212
@@ -227,10 +229,12 @@ export class GroupBy {
227229 if ( ! ops_name . includes ( op ) ) {
228230 throw new Error ( "operation does not exist" ) ;
229231 }
230- data = eval ( `this.group_col[key1][i].${ ops_map [ op ] } ` ) ;
232+ local = this . group_col [ key1 ] [ i ] ;
233+ data = eval ( `local.${ ops_map [ op ] } ` ) ;
231234
232235 } else {
233- data = eval ( `this.group_col[key1][i].${ operation } ` ) ;
236+ local = this . group_col [ key1 ] [ i ] ;
237+ data = eval ( `local.${ operation } ` ) ;
234238 }
235239
236240 count_group [ key1 ] . push ( data ) ;
0 commit comments