File tree Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 11In next release ...
22
3+ -  Use lookup table to optimize ` get `  method.
4+ 
35-  The ` connect `  method now returns a boolean status of whether the
46  connection is encrypted.
57
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export type ResultIterator = _ResultIterator<Value>;
5050
5151export  type  ResultRow  =  _ResultRow < Value > ; 
5252
53- export  type  Connect  =  ( Error  |  string   |   null ) ; 
53+ export  type  Connect  =  Error  |  null ; 
5454
5555export  type  End  =  void ; 
5656
Original file line number Diff line number Diff line change @@ -8,22 +8,25 @@ type ResultHandler = (resolve: Resolver) => void;
88type  Callback < T >  =  ( item : T )  =>  void ; 
99
1010export  class  ResultRow < T >  { 
11-     private  readonly  length :  number ; 
11+     private  readonly  lookup :  { [ name :  string ] :  number } ; 
1212
1313    constructor ( public  readonly  names : string [ ] ,  public  readonly  data : T [ ] )  { 
14-         this . length  =  names . length ; 
14+         const  lookup : { [ name : string ] : number }  =  { } ; 
15+         let  i  =  0 ; 
16+         for  ( const  name  of  names )  { 
17+             lookup [ name ]  =  i ; 
18+             i ++ ; 
19+         } 
20+         this . lookup  =  lookup ; 
1521    } 
1622
1723    [ Symbol . iterator ] ( ) : Iterator < T >  { 
18- 	 return  this . data [ Symbol . iterator ] ( ) ; 
24+          return  this . data [ Symbol . iterator ] ( ) ; 
1925    } 
2026
2127    get ( name : string ) : T  |  undefined  { 
22-         for  ( let  i  =  0 ;  i  <  this . length ;  i ++ )  { 
23-             if  ( this . names [ i ]  ===  name )  { 
24-                 return  this . data [ i ] ; 
25-             } 
26-         } 
28+         const  i  =  this . lookup [ name ] ; 
29+         return  this . data [ i ] ; 
2730    } 
2831} 
2932
Original file line number Diff line number Diff line change 1515      "allowSyntheticDefaultImports" : true ,
1616      "experimentalDecorators" : true ,
1717      "emitDecoratorMetadata" : true ,
18+       "noImplicitAny" : true ,
1819      "noUnusedParameters" : true ,
1920      "noUnusedLocals" : true ,
2021      "declarationDir" : " dist" 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments